From ec43caaa106eb76388bc83f21bc50dd26f948bab Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 10 Sep 2024 23:01:09 -0500 Subject: [PATCH] Add a test for the fix for #439, and start on #204 --- tests/integration/via.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/integration/via.js b/tests/integration/via.js index 1318c8a..c3823dd 100644 --- a/tests/integration/via.js +++ b/tests/integration/via.js @@ -1,14 +1,24 @@ -import * as utils from "../../utils.js"; import { describe, it } from "mocha"; import { TestMachine } from "./test-machine.js"; import assert from "assert"; +async function runViaProgram(source) { + const testMachine = new TestMachine(); + await testMachine.initialise(); + await testMachine.runUntilInput(); + await testMachine.loadBasic(source); + + testMachine.captureText((elem) => console.log(`emulator output: ${elem.text}`)); + await testMachine.type("RUN"); + await testMachine.runUntilInput(); + return testMachine; +} + describe("should pass scarybeasts' VIA tests", function () { // Code here extracted and paraphrased from the SSD zipfile from https://github.com/mattgodbolt/jsbeeb/issues/179 it("VIA.AC1 - Does ACR write restart timer?", async function () { - // REM REAL BBC! 64, 0, 0, 128 - // REM JSBEEB: 64, 0, 0, 128 - const source = ` + // Real BBC: 64, 0, 0, 128 + const testMachine = await runViaProgram(` DIM MC% 100 R% = &200 P% = MC% @@ -51,15 +61,7 @@ PRINT "REAL BBC: 64, 0, 0, 128" PRINT ?(R%) PRINT ?(R%+1) PRINT ?(R%+2) -PRINT ?(R%+3)`; - const testMachine = new TestMachine(); - await testMachine.initialise(); - await testMachine.runUntilInput(); - await testMachine.loadBasic(source); - - testMachine.captureText((elem) => console.log(`emulator output: ${elem.text}`)); - await testMachine.type("RUN"); - await testMachine.runUntilInput(); +PRINT ?(R%+3)`); assert.equal(testMachine.readbyte(0x200), 64); assert.equal(testMachine.readbyte(0x201), 0); assert.equal(testMachine.readbyte(0x202), 0);