Skip to content

Commit 11b7f1a

Browse files
committed
1 parent 4d0ded8 commit 11b7f1a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use lang\{ArrayType, MapType, Primitive, Type, Value, XPClass};
44
use test\verify\Runtime;
55
use test\{Action, Assert, Test, Values};
6+
use util\Binford;
67

78
class ParameterTest extends EmittingTest {
89
use AnnotationsOf, NullableSupport;
@@ -14,7 +15,7 @@ class ParameterTest extends EmittingTest {
1415
* @return lang.reflection.Parameter
1516
*/
1617
private function param($declaration) {
17-
return $this->declare('use lang\Value; class %T { public function fixture('.$declaration.') { } }')
18+
return $this->declare('use lang\Value; use util\Binford; class %T { public function fixture('.$declaration.') { } }')
1819
->method('fixture')
1920
->parameter(0)
2021
;
@@ -122,6 +123,18 @@ public function optional_parameters_default_value() {
122123
Assert::equals(true, $this->param('$param= true')->default());
123124
}
124125

126+
#[Test]
127+
public function new_as_default() {
128+
$power= $this->param('$power= new Binford(6100)')->default();
129+
Assert::equals(new Binford(6100), $power);
130+
}
131+
132+
#[Test]
133+
public function closure_as_default() {
134+
$function= $this->param('$op= fn($in) => $in * 2')->default();
135+
Assert::equals(2, $function(1));
136+
}
137+
125138
#[Test]
126139
public function trailing_comma_allowed() {
127140
$p= $this->declare('class %T { public function fixture($param, ) { } }')

0 commit comments

Comments
 (0)