Skip to content

Commit ff28975

Browse files
committed
1 parent 07b351a commit ff28975

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/php/lang/ast/unittest/emit/PipelinesTest.class.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use test\{Assert, Test, Values};
44

5+
/** @see https://wiki.php.net/rfc/pipe-operator-v3 */
56
class PipelinesTest extends EmittingTest {
67

78
#[Test]
@@ -129,4 +130,19 @@ public function run($arg) {
129130

130131
Assert::equals($expected, $r);
131132
}
133+
134+
#[Test]
135+
public function rfc_example() {
136+
$r= $this->run('class %T {
137+
public function run() {
138+
return "Hello World"
139+
|> "htmlentities"
140+
|> str_split(...)
141+
|> fn($x) => array_map(strtoupper(...), $x)
142+
|> fn($x) => array_filter($x, fn($v) => $v != "O")
143+
;
144+
}
145+
}');
146+
Assert::equals(['H', 'E', 'L', 'L', ' ', 'W', 'R', 'L', 'D'], array_values($r));
147+
}
132148
}

0 commit comments

Comments
 (0)