Improve parser tests

Ensure we can parse all scripts and move the parser tests to a parser test file for clarity
This commit is contained in:
Jordan Eldredge 2019-07-20 18:34:56 -07:00
parent 6b03a353e7
commit 7bede9cd5a
3 changed files with 37 additions and 8 deletions

View file

@ -3,14 +3,7 @@ const path = require("path");
const System = require("../runtime/System");
const runtime = require("../runtime");
const interpret = require("./interpreter");
const VERSIONS = {
WINAMP_3_ALPHA: "v1.1.0.a9 (Winamp 3 alpha 8r)",
WINAMP_3_BETA: "v1.1.1.b3 (Winamp 3.0 build 488d)",
WINAMP_3_FULL: "v1.1.1.b3 (Winamp 3.0 full)",
WINAMP_5_02: "v1.1.13 (Winamp 5.02)",
WINAMP_5_66: "v1.2.0 (Winamp 5.66)",
};
const { VERSIONS } = require("./testConstants");
async function runFile(relativePath) {
const system = new System();

View file

@ -2,12 +2,41 @@ const fs = require("fs");
const path = require("path");
const parse = require("./parser");
const { getClass } = require("./objects");
const { VERSIONS } = require("./testConstants");
function parseFile(relativePath) {
const buffer = fs.readFileSync(path.join(__dirname, relativePath));
return parse(buffer);
}
describe("can parse without crashing", () => {
const versions = [
// VERSIONS.WINAMP_3_ALPHA,
VERSIONS.WINAMP_3_BETA,
VERSIONS.WINAMP_3_FULL,
VERSIONS.WINAMP_5_02,
VERSIONS.WINAMP_5_66,
];
const scripts = [
"hello_world.maki",
"basicTests.maki",
"simpleFunctions.maki",
];
scripts.forEach(script => {
describe(`script ${script}`, () => {
versions.forEach(version => {
test(`compiled with compiler version ${version}`, () => {
expect(() => {
parseFile(`./reference/maki_compiler/${version}/${script}`);
}).not.toThrow();
});
});
});
});
});
describe("standardframe.maki", () => {
let maki;
beforeEach(() => {

View file

@ -0,0 +1,7 @@
export const VERSIONS = {
WINAMP_3_ALPHA: "v1.1.0.a9 (Winamp 3 alpha 8r)",
WINAMP_3_BETA: "v1.1.1.b3 (Winamp 3.0 build 488d)",
WINAMP_3_FULL: "v1.1.1.b3 (Winamp 3.0 full)",
WINAMP_5_02: "v1.1.13 (Winamp 5.02)",
WINAMP_5_66: "v1.2.0 (Winamp 5.66)",
};