Skip to content

Commit ed8144e

Browse files
committed
Verify both short (fn) and long (function) closures work
1 parent f37e113 commit ed8144e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ private function expressions() {
2727
}
2828

2929
#[Test, Values('expressions')]
30-
public function property($code, $expected) {
30+
public function property($declaration, $expected) {
3131
Assert::equals($expected, $this->run(sprintf('use lang\ast\unittest\emit\Handle; class <T> {
3232
const INITIAL= "initial";
3333
private $h= %s;
3434
3535
public function run() {
3636
return $this->h;
3737
}
38-
}', $code)));
38+
}', $declaration)));
3939
}
4040

41-
#[Test]
42-
public function using_functions() {
43-
$r= $this->run('class <T> {
44-
private $h= fn($arg) => $arg->redirect(1);
41+
#[Test, Values(['fn($arg) => $arg->redirect(1)', 'function($arg) { return $arg->redirect(1); }'])]
42+
public function using_closures($declaration) {
43+
$r= $this->run(sprintf('class <T> {
44+
private $h= %s;
4545
4646
public function run() {
4747
return $this->h;
4848
}
49-
}');
49+
}', $declaration));
5050
Assert::equals(new Handle(1), $r(new Handle(0)));
5151
}
5252

@@ -62,7 +62,6 @@ public function run() {
6262
Assert::equals(new Handle(1), $r->pipe(new Handle(0)));
6363
}
6464

65-
6665
#[Test]
6766
public function property_initialization_accessible_inside_constructor() {
6867
$r= $this->run('use lang\ast\unittest\emit\Handle; class <T> {

0 commit comments

Comments
 (0)