3
3
use lang \{ArrayType , MapType , Primitive , Type , Value , XPClass };
4
4
use test \verify \Runtime ;
5
5
use test \{Action , Assert , Test , Values };
6
+ use util \Binford ;
6
7
7
8
class ParameterTest extends EmittingTest {
8
9
use AnnotationsOf, NullableSupport;
@@ -14,7 +15,7 @@ class ParameterTest extends EmittingTest {
14
15
* @return lang.reflection.Parameter
15
16
*/
16
17
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 .') { } } ' )
18
19
->method ('fixture ' )
19
20
->parameter (0 )
20
21
;
@@ -122,6 +123,18 @@ public function optional_parameters_default_value() {
122
123
Assert::equals (true , $ this ->param ('$param= true ' )->default ());
123
124
}
124
125
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
+
125
138
#[Test]
126
139
public function trailing_comma_allowed () {
127
140
$ p = $ this ->declare ('class %T { public function fixture($param, ) { } } ' )
0 commit comments