File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/test/php/lang/ast/unittest/emit Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -162,4 +162,35 @@ public function run($arg) {
162
162
}
163
163
} ' , SEEK_END );
164
164
}
165
+
166
+ #[Test]
167
+ public function match_without_arg_inside_fn () {
168
+ $ r = $ this ->run ('class <T> {
169
+ public function run() {
170
+ return fn($arg) => match {
171
+ $arg >= 10 => "10+ items",
172
+ $arg === 1 => "one item",
173
+ $arg === 0 => "no items",
174
+ default => $arg." items",
175
+ };
176
+ }
177
+ } ' );
178
+
179
+ Assert::equals ('10+ items ' , $ r (10 ));
180
+ }
181
+
182
+ #[Test]
183
+ public function match_with_arg_inside_fn () {
184
+ $ r = $ this ->run ('class <T> {
185
+ public function run() {
186
+ return fn($arg) => match ($arg) {
187
+ 0 => "no items",
188
+ 1 => "one item",
189
+ default => $arg." items",
190
+ };
191
+ }
192
+ } ' );
193
+
194
+ Assert::equals ('one item ' , $ r (1 ));
195
+ }
165
196
}
You can’t perform that action at this time.
0 commit comments