Skip to content

Commit 8547304

Browse files
committed
Add test casting_used_for_coercion()
1 parent 14e064f commit 8547304

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,22 @@ public static function fixture($arg) {
7878
$this->invokeFixture($t->newGenericType([Primitive::$STRING]), [$value])
7979
);
8080
}
81+
82+
#[Test]
83+
public function casting_used_for_coercion() {
84+
$t= $this->type('class %T<T> {
85+
private $begin, $end;
86+
87+
public function __construct($range) {
88+
[$this->begin, $this->end]= (array<T>)$range;
89+
}
90+
91+
public function begin(): T { return $this->begin; }
92+
93+
public function end(): T { return $this->end; }
94+
}');
95+
96+
$range= $t->newGenericType([Primitive::$INT])->newInstance(['1', '10']);
97+
Assert::equals([1, 10], [$range->begin(), $range->end()]);
98+
}
8199
}

0 commit comments

Comments
 (0)