Skip to content

Commit adb313c

Browse files
committed
Add tests for braces in various situations
1 parent cccb6d8 commit adb313c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php namespace lang\ast\unittest\emit;
2+
3+
class BracesTest extends EmittingTest {
4+
5+
#[@test]
6+
public function inc() {
7+
$r= $this->run('class <T> {
8+
private $id= 0;
9+
10+
public function run() {
11+
return "test".(++$this->id);
12+
}
13+
}');
14+
15+
$this->assertEquals('test1', $r);
16+
}
17+
18+
#[@test]
19+
public function no_braces_necessary_around_new() {
20+
$r= $this->run('class <T> {
21+
public function run() {
22+
return new \\util\\Date(250905600)->getTime();
23+
}
24+
}');
25+
26+
$this->assertEquals(250905600, $r);
27+
}
28+
29+
#[@test]
30+
public function property_vs_method_ambiguity() {
31+
$r= $this->run('class <T> {
32+
private $f;
33+
34+
public function __construct() {
35+
$this->f= function($arg) { return $arg; };
36+
}
37+
38+
public function run() {
39+
return ($this->f)("test");
40+
}
41+
}');
42+
43+
$this->assertEquals('test', $r);
44+
}
45+
}

0 commit comments

Comments
 (0)