implements PR-19.9 conformance fixtures diagnostics and gate closure
This commit is contained in:
+69
@@ -308,6 +308,8 @@ class PBSFrontendPhaseServiceTest {
|
||||
|
||||
assertTrue(diagnostics.isEmpty(), diagnostics.stream().map(d -> d.getCode() + ":" + d.getMessage()).toList().toString());
|
||||
assertTrue(irBackend.getEntryPointCallableName().startsWith("__pbs.frame_wrapper$m"));
|
||||
assertTrue(irBackend.getGlobals().stream().anyMatch(global ->
|
||||
global.name().startsWith("__pbs.boot_guard$m")));
|
||||
final var wrapper = irBackend.getExecutableFunctions().stream()
|
||||
.filter(function -> irBackend.getEntryPointCallableName().equals(function.callableName()))
|
||||
.findFirst()
|
||||
@@ -319,6 +321,73 @@ class PBSFrontendPhaseServiceTest {
|
||||
assertEquals(p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.RET, wrapper.instructions().get(3).kind());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldSynthesizePositiveTopic19FixtureAcrossFileInitProjectInitAndFrame() throws IOException {
|
||||
final var projectRoot = tempDir.resolve("project-topic-19-positive");
|
||||
final var sourceRoot = projectRoot.resolve("src");
|
||||
final var modulePath = sourceRoot.resolve("game");
|
||||
Files.createDirectories(modulePath);
|
||||
|
||||
final var globalsSource = modulePath.resolve("globals.pbs");
|
||||
final var mainSource = modulePath.resolve("main.pbs");
|
||||
final var modBarrel = modulePath.resolve("mod.barrel");
|
||||
Files.writeString(globalsSource, """
|
||||
declare global SCORE: int = 0;
|
||||
|
||||
[Init]
|
||||
fn warmup() -> void { return; }
|
||||
""");
|
||||
Files.writeString(mainSource, """
|
||||
[Init]
|
||||
fn boot() -> void { return; }
|
||||
|
||||
[Frame]
|
||||
fn frame() -> void { return; }
|
||||
""");
|
||||
Files.writeString(modBarrel, """
|
||||
pub fn warmup() -> void;
|
||||
pub fn boot() -> void;
|
||||
pub fn frame() -> void;
|
||||
pub global SCORE;
|
||||
""");
|
||||
|
||||
final var projectTable = new ProjectTable();
|
||||
final var fileTable = new FileTable(1);
|
||||
final var projectId = projectTable.register(ProjectDescriptor.builder()
|
||||
.rootPath(projectRoot)
|
||||
.name("core")
|
||||
.version("1.0.0")
|
||||
.sourceRoots(ReadOnlyList.wrap(List.of(sourceRoot)))
|
||||
.build());
|
||||
|
||||
registerFile(projectId, projectRoot, globalsSource, fileTable);
|
||||
registerFile(projectId, projectRoot, mainSource, fileTable);
|
||||
registerFile(projectId, projectRoot, modBarrel, fileTable);
|
||||
|
||||
final var ctx = new FrontendPhaseContext(
|
||||
projectTable,
|
||||
fileTable,
|
||||
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
|
||||
final var irBackend = new PBSFrontendPhaseService().compile(
|
||||
ctx,
|
||||
diagnostics,
|
||||
LogAggregator.empty(),
|
||||
BuildingIssueSink.empty());
|
||||
|
||||
assertTrue(diagnostics.isEmpty(), diagnostics.stream().map(d -> d.getCode() + ":" + d.getMessage()).toList().toString());
|
||||
assertTrue(irBackend.getEntryPointCallableName().startsWith("__pbs.frame_wrapper$m"));
|
||||
assertTrue(irBackend.getExecutableFunctions().stream().anyMatch(function ->
|
||||
function.callableName().startsWith("__pbs.file_init$f")));
|
||||
assertTrue(irBackend.getExecutableFunctions().stream().anyMatch(function ->
|
||||
function.callableName().startsWith("__pbs.module_init$m")));
|
||||
assertTrue(irBackend.getExecutableFunctions().stream().anyMatch(function ->
|
||||
function.callableName().startsWith("__pbs.project_init$m")));
|
||||
assertTrue(irBackend.getGlobals().stream().anyMatch(global -> "SCORE".equals(global.name())));
|
||||
assertTrue(irBackend.getGlobals().stream().anyMatch(global -> global.name().startsWith("__pbs.boot_guard$m")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldSkipIrLoweringForSourcesMarkedAsSdkInterface() throws IOException {
|
||||
final var projectRoot = tempDir.resolve("project-sdk-interface");
|
||||
|
||||
Reference in New Issue
Block a user