1
1
<?php namespace lang \ast \unittest \emit ;
2
2
3
+ use Closure ;
3
4
use lang \Error ;
4
5
use test \verify \Runtime ;
5
6
use test \{Assert , Expect , Test , Values };
@@ -23,33 +24,33 @@ private function verify($code) {
23
24
Assert::equals (4 , $ this ->run ($ code )('Test ' ));
24
25
}
25
26
26
- #[Test]
27
- public function native_function_variadic ( ) {
28
- $ this ->verify ('class %T {
29
- public function run() { return strlen(...) ; }
30
- } ' );
27
+ #[Test, Values([ ' strlen(...) ' , ' strlen(?) ' ]) ]
28
+ public function returns_closure ( $ notation ) {
29
+ Assert:: instance (Closure::class, $ this ->run ('class %T {
30
+ public function run() { return ' . $ notation . ' ; }
31
+ } ' )) ;
31
32
}
32
33
33
- #[Test]
34
- public function native_function_argument ( ) {
34
+ #[Test, Values([ ' strlen(...) ' , ' strlen(?) ' ]) ]
35
+ public function native_function ( $ notation ) {
35
36
$ this ->verify ('class %T {
36
- public function run() { return strlen(?) ; }
37
+ public function run() { return ' . $ notation . ' ; }
37
38
} ' );
38
39
}
39
40
40
- #[Test]
41
- public function instance_method () {
41
+ #[Test, Values([ ' $this->length(...) ' , ' $this->length(?) ' ]) ]
42
+ public function instance_method ($ notation ) {
42
43
$ this ->verify ('class %T {
43
44
public function length($arg) { return strlen($arg); }
44
- public function run() { return $this->length(...) ; }
45
+ public function run() { return ' . $ notation . ' ; }
45
46
} ' );
46
47
}
47
48
48
- #[Test]
49
- public function class_method () {
49
+ #[Test, Values([ ' self::length(...) ' , ' self::length(?) ' ]) ]
50
+ public function class_method ($ notation ) {
50
51
$ this ->verify ('class %T {
51
52
public static function length($arg) { return strlen($arg); }
52
- public function run() { return self::length(...) ; }
53
+ public function run() { return ' . $ notation . ' ; }
53
54
} ' );
54
55
}
55
56
@@ -159,8 +160,8 @@ public function run() {
159
160
} ' );
160
161
}
161
162
162
- #[Test]
163
- public function instantiation_variadic ( ) {
163
+ #[Test, Values([ ' new Handle(...) ' , ' new Handle(?) ' ]) ]
164
+ public function instantiation ( $ notation ) {
164
165
$ f = $ this ->run ('use lang\ast\unittest\emit\Handle; class %T {
165
166
public function run() {
166
167
return new Handle(...);
@@ -169,16 +170,6 @@ public function run() {
169
170
Assert::equals (new Handle (1 ), $ f (1 ));
170
171
}
171
172
172
- #[Test]
173
- public function instantiation_argument () {
174
- $ f = $ this ->run ('use lang\ast\unittest\emit\Handle; class %T {
175
- public function run() {
176
- return new Handle(?);
177
- }
178
- } ' );
179
- Assert::equals (new Handle (1 ), $ f (1 ));
180
- }
181
-
182
173
#[Test]
183
174
public function instantiation_in_map () {
184
175
$ r = $ this ->run ('use lang\ast\unittest\emit\Handle; class %T {
0 commit comments