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.
34 lines
1.0 KiB
34 lines
1.0 KiB
<?php
|
|
|
|
use TypePhp\CompilerTest;
|
|
|
|
final class ClassConstantCodegenTest extends \BaseTest
|
|
{
|
|
public function testThisConstantIsExpandedButUnknownObjectUsesRuntimeLookup(): void
|
|
{
|
|
$code = $this->compileFixture();
|
|
|
|
self::assertMatchesRegularExpression(
|
|
'/php_classconstantcodegen__readthis\([^)]*\)[\s\S]*?= \(23L\);/',
|
|
$code,
|
|
);
|
|
self::assertStringContainsString('php::classConstant(', $code);
|
|
self::assertStringNotContainsString('php::constant(php::concat({', $code);
|
|
}
|
|
|
|
private function compileFixture(): string
|
|
{
|
|
global $translator;
|
|
|
|
$compiler = CompilerTest::create(ROOT_PATH);
|
|
$translator = $compiler;
|
|
$source = ROOT_PATH . '/phpunit/code/class-constant-codegen.php';
|
|
$compiler->addFiles([$source]);
|
|
$compiler->prepareFile($source);
|
|
$generated = $compiler->convertFile($source);
|
|
$code = file_get_contents($generated);
|
|
|
|
self::assertIsString($code);
|
|
return $code;
|
|
}
|
|
}
|
|
|