TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
989 B
39 lines
989 B
<?php
|
|
|
|
|
|
use TypePhp\CompilerTest;
|
|
use TypePhp\Exception\TestError;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class DuplicateTest extends TestCase
|
|
{
|
|
private function exec(string $expected, string $file): void
|
|
{
|
|
try {
|
|
$compiler = CompilerTest::create(ROOT_PATH);
|
|
$testFile = __DIR__ . '/../code/' . $file;
|
|
$compiler->addFiles([$testFile]);
|
|
$compiler->prepareFile($testFile);
|
|
$compiler->convertFile($testFile);
|
|
} catch (TestError $exception) {
|
|
$this->assertStringContainsString($expected, $exception->getMessage());
|
|
return;
|
|
}
|
|
$this->fail();
|
|
}
|
|
|
|
public function testStaticVar()
|
|
{
|
|
$this->exec('Duplicate variable', 'duplicate_01.php');
|
|
}
|
|
|
|
public function testFunction()
|
|
{
|
|
$this->exec('Duplicate function', 'duplicate_02.php');
|
|
}
|
|
|
|
public function testClass()
|
|
{
|
|
$this->exec('Duplicate class', 'duplicate_03.php');
|
|
}
|
|
}
|
|
|