Skip to content

Commit

Permalink
Test instanceof operator with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Aug 4, 2024
1 parent 0468d7c commit 9936f81
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/test/php/lang/ast/unittest/parse/OperatorTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
UnaryExpression,
Variable
};
use lang\ast\types\{IsExpression, IsValue};
use lang\ast\types\{IsExpression, IsGeneric, IsValue};
use test\{Assert, Test, Values};

class OperatorTest extends ParseTest {
Expand Down Expand Up @@ -283,6 +283,18 @@ public function precedence_of_not_and_instance_of() {
);
}

#[Test]
public function instanceof_generic() {
$this->assertParsed(
[new InstanceOfExpression(
new Variable('this', self::LINE),
new IsGeneric(new IsValue('self'), [new IsValue('T')]),
self::LINE
)],
'$this instanceof self<T>;'
);
}

#[Test, Values(['+', '-', '~'])]
public function precedence_of_prefix($operator) {
$this->assertParsed(
Expand Down

0 comments on commit 9936f81

Please sign in to comment.