mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Add a real test harness.
This commit is contained in:
parent
82815e5b85
commit
6a5fd9cf0c
@ -29,7 +29,7 @@
|
|||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": [ "bin/*", "webpack.config.js" ],
|
"files": [ "bin/*", "babel.config.js", "webpack.config.js" ],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": 0
|
"no-console": 0
|
||||||
},
|
},
|
||||||
@ -38,6 +38,11 @@
|
|||||||
"jquery": false,
|
"jquery": false,
|
||||||
"browser": false
|
"browser": false
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"files": [ "test/*"],
|
||||||
|
"env": {
|
||||||
|
"jest": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
13
babel.config.js
Normal file
13
babel.config.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// babel.config.js
|
||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 'current',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
};
|
51
js/test.js
51
js/test.js
@ -1,51 +0,0 @@
|
|||||||
import CPU6502 from './cpu6502';
|
|
||||||
import Test6502 from './6502test';
|
|
||||||
import Test65C02 from './65C02test';
|
|
||||||
import { toHex } from './util';
|
|
||||||
|
|
||||||
var SYMBOLS = {};
|
|
||||||
var cpu;
|
|
||||||
var trace = [];
|
|
||||||
var lastPC = 0;
|
|
||||||
var done = false;
|
|
||||||
function traceCB() {
|
|
||||||
var pc = cpu.getPC();
|
|
||||||
done = lastPC == pc;
|
|
||||||
lastPC = pc;
|
|
||||||
var line = cpu.dumpRegisters() + ' ' + cpu.dumpPC(undefined, SYMBOLS);
|
|
||||||
trace.push(line);
|
|
||||||
if (trace.length > 1000) {
|
|
||||||
trace.shift();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.test6502 = function test6502() {
|
|
||||||
cpu = new CPU6502();
|
|
||||||
var test = new Test6502();
|
|
||||||
cpu.addPageHandler(test);
|
|
||||||
cpu.setPC(0x400);
|
|
||||||
do {
|
|
||||||
cpu.stepCyclesDebug(1000, traceCB);
|
|
||||||
} while (!done);
|
|
||||||
|
|
||||||
if (lastPC == 0x3469) {
|
|
||||||
window.alert('6502 Success!');
|
|
||||||
} else {
|
|
||||||
window.alert('Failed! ' + toHex(lastPC));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.test65C02 = function test65C02() {
|
|
||||||
cpu = new CPU6502({'65C02': true});
|
|
||||||
var test = new Test65C02();
|
|
||||||
cpu.addPageHandler(test);
|
|
||||||
cpu.setPC(0x400);
|
|
||||||
do {
|
|
||||||
cpu.stepCyclesDebug(1000, traceCB);
|
|
||||||
} while (!done);
|
|
||||||
if (lastPC == 0x24f1) {
|
|
||||||
window.alert('65C02 Success!');
|
|
||||||
} else {
|
|
||||||
window.alert('Failed! ' + toHex(lastPC));
|
|
||||||
}
|
|
||||||
};
|
|
3106
package-lock.json
generated
3106
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,8 @@
|
|||||||
"dev": "webpack-dev-server",
|
"dev": "webpack-dev-server",
|
||||||
"index": "scripts/index.pl > json/disks/index.js",
|
"index": "scripts/index.pl > json/disks/index.js",
|
||||||
"lint": "eslint js",
|
"lint": "eslint js",
|
||||||
"start": "webpack-dev-server"
|
"start": "webpack-dev-server",
|
||||||
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -20,8 +21,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/whscullin/apple2js#readme",
|
"homepage": "https://github.com/whscullin/apple2js#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.4.0",
|
||||||
|
"@babel/preset-env": "^7.4.2",
|
||||||
"ajv": "^6.9.2",
|
"ajv": "^6.9.2",
|
||||||
|
"babel-jest": "^24.5.0",
|
||||||
"eslint": "^5.12.0",
|
"eslint": "^5.12.0",
|
||||||
|
"jest": "^24.5.0",
|
||||||
"webpack": "^4.29.6",
|
"webpack": "^4.29.6",
|
||||||
"webpack-cli": "^3.2.3",
|
"webpack-cli": "^3.2.3",
|
||||||
"webpack-dev-server": "^3.2.1"
|
"webpack-dev-server": "^3.2.1"
|
||||||
|
11
test.html
11
test.html
@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Test</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="dist/test.js"></script>
|
|
||||||
<button onclick="test6502()">Test 6502</button>
|
|
||||||
<button onclick="test65C02()">Test 65C02</button>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
46
test/cpu.spec.js
Normal file
46
test/cpu.spec.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
import CPU6502 from '../js/cpu6502';
|
||||||
|
import Test6502 from '../js/roms/6502test';
|
||||||
|
import Test65C02 from '../js/roms/65C02test';
|
||||||
|
|
||||||
|
var cpu;
|
||||||
|
var lastPC = 0;
|
||||||
|
var done = false;
|
||||||
|
|
||||||
|
function traceCB() {
|
||||||
|
var pc = cpu.getPC();
|
||||||
|
done = lastPC == pc;
|
||||||
|
lastPC = pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('CPU', function () {
|
||||||
|
describe('6502', function () {
|
||||||
|
it('completes the test ROM', function () {
|
||||||
|
cpu = new CPU6502();
|
||||||
|
var test = new Test6502();
|
||||||
|
cpu.addPageHandler(test);
|
||||||
|
cpu.setPC(0x400);
|
||||||
|
|
||||||
|
do {
|
||||||
|
cpu.stepCyclesDebug(1000, traceCB);
|
||||||
|
} while (!done);
|
||||||
|
|
||||||
|
expect(lastPC).toEqual(0x3469);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('65C02', function () {
|
||||||
|
it('completes the test ROM', function () {
|
||||||
|
cpu = new CPU6502({'65C02': true});
|
||||||
|
var test = new Test65C02();
|
||||||
|
cpu.addPageHandler(test);
|
||||||
|
cpu.setPC(0x400);
|
||||||
|
|
||||||
|
do {
|
||||||
|
cpu.stepCyclesDebug(1000, traceCB);
|
||||||
|
} while (!done);
|
||||||
|
|
||||||
|
expect(lastPC).toEqual(0x24f1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user