Skip to content

Commit e98f4df

Browse files
committed
Improve tests for AST printing, still doesn't work.
1 parent 8142547 commit e98f4df

File tree

1 file changed

+73
-5
lines changed

1 file changed

+73
-5
lines changed

Zend/tests/pipe_operator/ast.phpt

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--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.
33
--FILE--
44
<?php
5-
5+
/*
66
function _test(int $a): int {
77
return $a + 1;
88
}
@@ -28,9 +28,77 @@ try {
2828
} catch (AssertionError $e) {
2929
echo $e->getMessage(), PHP_EOL;
3030
}
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+
}
3191

3292
?>
3393
--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

Comments
 (0)