|
1 | 1 | --TEST--
|
2 |
| -Test that a pipe operator displays as a pipe operator when outputting syntax. |
| 2 | +A pipe operator displays as a pipe operator when outputting syntax, with correct parens. |
3 | 3 | --FILE--
|
4 | 4 | <?php
|
5 |
| - |
| 5 | +/* |
6 | 6 | function _test(int $a): int {
|
7 | 7 | return $a + 1;
|
8 | 8 | }
|
|
28 | 28 | } catch (AssertionError $e) {
|
29 | 29 | echo $e->getMessage(), PHP_EOL;
|
30 | 30 | }
|
| 31 | +*/ |
| 32 | + |
| 33 | +print "Concat, which binds higher\n"; |
| 34 | + |
| 35 | +try { |
| 36 | + assert(false && foo() . bar() |> baz() . quux()); |
| 37 | +} catch (AssertionError $e) { |
| 38 | + echo $e->getMessage(), PHP_EOL; |
| 39 | +} |
| 40 | + |
| 41 | +try { |
| 42 | + assert(false && (foo() . bar()) |> baz() . quux()); |
| 43 | +} catch (AssertionError $e) { |
| 44 | + echo $e->getMessage(), PHP_EOL; |
| 45 | +} |
| 46 | + |
| 47 | +try { |
| 48 | + assert(false && foo() . (bar() |> baz()) . quux()); |
| 49 | +} catch (AssertionError $e) { |
| 50 | + echo $e->getMessage(), PHP_EOL; |
| 51 | +} |
| 52 | + |
| 53 | +try { |
| 54 | + assert(false && foo() . bar() |> (baz() . quux())); |
| 55 | +} catch (AssertionError $e) { |
| 56 | + echo $e->getMessage(), PHP_EOL; |
| 57 | +} |
| 58 | + |
| 59 | +try { |
| 60 | + assert(false && (foo() . bar() |> baz()) . quux()); |
| 61 | +} catch (AssertionError $e) { |
| 62 | + echo $e->getMessage(), PHP_EOL; |
| 63 | +} |
| 64 | + |
| 65 | +try { |
| 66 | + assert(false && foo() . (bar() |> baz() . quux())); |
| 67 | +} catch (AssertionError $e) { |
| 68 | + echo $e->getMessage(), PHP_EOL; |
| 69 | +} |
| 70 | + |
| 71 | +print "<, which binds lower\n"; |
| 72 | + |
| 73 | +try { |
| 74 | + assert(false && foo() < bar() |> baz()); |
| 75 | +} catch (AssertionError $e) { |
| 76 | + echo $e->getMessage(), PHP_EOL; |
| 77 | +} |
| 78 | + |
| 79 | +try { |
| 80 | + // Currently wrong |
| 81 | + assert(false && (foo() < bar()) |> baz()); |
| 82 | +} catch (AssertionError $e) { |
| 83 | + echo $e->getMessage(), PHP_EOL; |
| 84 | +} |
| 85 | + |
| 86 | +try { |
| 87 | + assert(false && foo() < (bar() |> baz())); |
| 88 | +} catch (AssertionError $e) { |
| 89 | + echo $e->getMessage(), PHP_EOL; |
| 90 | +} |
31 | 91 |
|
32 | 92 | ?>
|
33 | 93 | --EXPECTF--
|
34 |
| -assert((5 |> '_test') == 99) |
35 |
| -assert((5 |> _test(...)) == 99) |
36 |
| -assert(5 |> abool(...)) |
| 94 | +Concat, which binds higher |
| 95 | +assert(false && (foo() . bar() |> baz() . quux())) |
| 96 | +assert(false && (foo() . bar() |> baz() . quux())) |
| 97 | +assert(false && foo() . (bar() |> baz()) . quux()) |
| 98 | +assert(false && (foo() . bar() |> baz() . quux())) |
| 99 | +assert(false && (foo() . bar() |> baz()) . quux()) |
| 100 | +assert(false && foo() . (bar() |> baz() . quux())) |
| 101 | +<, which binds lower |
| 102 | +assert(false && foo() < bar() |> baz()) |
| 103 | +assert(false && (foo() < bar()) |> baz()) |
| 104 | +assert(false && foo() < (bar() |> baz())) |
0 commit comments