33use lang \{ArrayType , MapType , Primitive , Type , Value , XPClass };
44use test \verify \Runtime ;
55use test \{Action , Assert , Test , Values };
6+ use util \Binford ;
67
78class 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