feat(studio): integrate memcard persistence and headless controls
Persist cartridge identity and slot configuration, add MemcardBoot and the MemcardBuffer SDK, and consume the runtime's negotiated memcard host controls with protected teardown. Qualify save/reopen and version upgrades through distinct configured runtime processes. Include specs, examples, regression evidence and the consolidated discussion lesson.
This commit is contained in:
+27
@@ -14,6 +14,33 @@ import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class PbsGuestLifecycleSemanticsTest {
|
||||
@Test void memcardRequiresExactTypedSignatureAndKeepsSourceDiagnostics() {
|
||||
var valid = "[MemcardBoot] fn arbitrary(context: long) -> int { return 0; }";
|
||||
var diagnostics = DiagnosticSink.empty();
|
||||
new PbsFrontendCompiler().compileFile(new FileId(9), valid, diagnostics);
|
||||
assertFalse(diagnostics.hasErrors(), diagnostics.stream().map(d -> d.getMessage()).toList().toString());
|
||||
assertTrue(new PBSSemanticTokenProvider().tokenize(valid).stream().anyMatch(t -> t.semanticKey().equals("pbs-lifecycle")));
|
||||
for (var source : List.of(
|
||||
"[MemcardBoot] fn bad() -> int { return 0; }",
|
||||
"[MemcardBoot] fn bad(c: int) -> int { return 0; }",
|
||||
"[MemcardBoot] fn bad(c: long) -> long { return 0 as long; }",
|
||||
"[MemcardBoot] fn bad<T>(c: long) -> int { return 0; }",
|
||||
"[MemcardBoot(value = 1)] fn bad(c: long) -> int { return 0; }",
|
||||
"[MemcardBoot][BeforePause] fn bad(c: long) -> int { return 0; }",
|
||||
"declare service Bad { [MemcardBoot] fn bad(c: long) -> int { return 0; } }")) {
|
||||
var errors = DiagnosticSink.empty();
|
||||
new PbsFrontendCompiler().compileFile(new FileId(9), source, errors);
|
||||
assertTrue(errors.hasErrors(), source);
|
||||
}
|
||||
var first = file(1, valid);
|
||||
var second = file(2, valid.replace("arbitrary", "conflict"));
|
||||
var frame = file(0, "[Frame] fn frame() -> void {}");
|
||||
diagnostics = DiagnosticSink.empty();
|
||||
new PbsProjectLifecycleSemanticsValidator().validate(List.of(frame, first, first), diagnostics);
|
||||
assertFalse(diagnostics.hasErrors());
|
||||
new PbsProjectLifecycleSemanticsValidator().validate(List.of(frame, first, second), diagnostics);
|
||||
assertTrue(diagnostics.stream().anyMatch(d -> d.getCode().equals("E_SEM_DUPLICATE_LIFECYCLE_ROLE")));
|
||||
}
|
||||
@Test void permitsGlobalsClosuresAndDocOnBothHooks() {
|
||||
var source = """
|
||||
declare global state: int = 0;
|
||||
|
||||
Reference in New Issue
Block a user