Skip to content

Commit 40c4a82

Browse files
committed
Add test for match statement
1 parent 42a4a93 commit 40c4a82

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/test/php/lang/ast/syntax/php/unittest/IsOperatorTest.class.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace lang\ast\syntax\php\unittest;
22

33
use lang\ast\unittest\emit\EmittingTest;
4-
use test\{Assert, Test};
4+
use test\{Assert, Test, Values};
55

66
class IsOperatorTest extends EmittingTest {
77

@@ -197,4 +197,18 @@ public function run() {
197197

198198
Assert::equals('string <Test>', $r);
199199
}
200+
201+
#[Test, Values([[1, 'int'], ['test', 'string']])]
202+
public function with_match_statement($arg, $expected) {
203+
$r= $this->run('class <T> {
204+
public function run(string|int $arg) {
205+
return match {
206+
$arg is string => "string",
207+
$arg is int => "int",
208+
};
209+
}
210+
}', $arg);
211+
212+
Assert::equals($expected, $r);
213+
}
200214
}

0 commit comments

Comments
 (0)