Skip to content

Commit fabaf40

Browse files
committed
Edited the tests to make it work onto GitHub
1 parent 68c97ce commit fabaf40

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

test/generator.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// import { describe, it } from "node:test";
2-
// import assert from "node:assert/strict";
3-
// import parse from "../src/parser.js";
4-
// import analyze from "../src/analyzer.js";
5-
// import generate from "../src/generator.js";
1+
import { describe, it } from "node:test";
2+
import assert from "node:assert/strict";
3+
import parse from "../src/parser.js";
4+
import analyze from "../src/analyzer.js";
5+
import generate from "../src/generator.js";
66

7-
// function dedent(s) {
8-
// return `${s}`.replace(/(?<=\n)\s+/g, "").trim();
9-
// }
7+
function dedent(s) {
8+
return `${s}`.replace(/(?<=\n)\s+/g, "").trim();
9+
}
1010

1111
const fixtures = [
1212
{
@@ -1258,11 +1258,11 @@ const fixtures = [
12581258
},
12591259
];
12601260

1261-
// describe("The code generator", () => {
1262-
// for (const fixture of fixtures) {
1263-
// it(`produces expected js output for the ${fixture.name} program`, () => {
1264-
// const actual = dedent(generate(analyze(parse(fixture.source))));
1265-
// assert.equal(actual.trim(), fixture.expected.trim());
1266-
// });
1267-
// }
1268-
// });
1261+
describe("The code generator", () => {
1262+
for (const fixture of fixtures) {
1263+
it(`produces expected js output for the ${fixture.name} program`, () => {
1264+
const actual = dedent(generate(analyze(parse(fixture.source))));
1265+
assert.equal(actual.trim(), fixture.expected.trim());
1266+
});
1267+
}
1268+
});

test/optimizer.test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// import { describe, it } from "node:test";
2-
// import assert from "node:assert/strict";
3-
// import optimize from "../src/optimizer.js";
4-
// import * as core from "../src/core.js";
1+
import { describe, it } from "node:test";
2+
import assert from "node:assert/strict";
3+
import optimize from "../src/optimizer.js";
4+
import * as core from "../src/core.js";
55

6-
// const num = (value) => core.num(value);
7-
// const add = (left, op, right) => core.addExpr(left, op, right);
8-
// const mul = (left, op, right) => core.mulExpr(left, op, right);
9-
// const condExpr = (left, op, right, then, elseB) => core.condExpr(left, op, right, then, elseB);
10-
// const id = (name) => core.id(name);
6+
const num = (value) => core.num(value);
7+
const add = (left, op, right) => core.addExpr(left, op, right);
8+
const mul = (left, op, right) => core.mulExpr(left, op, right);
9+
const condExpr = (left, op, right, then, elseB) => core.condExpr(left, op, right, then, elseB);
10+
const id = (name) => core.id(name);
1111

1212
const tests = [
1313
[
@@ -311,11 +311,11 @@ const tests = [
311311
],
312312
];
313313

314-
// describe("The optimizer", () => {
315-
// for (const [scenario, before, after] of tests) {
316-
// it(scenario, () => {
317-
// const result = optimize(before);
318-
// assert.deepEqual(result, after);
319-
// });
320-
// }
321-
// });
314+
describe("The optimizer", () => {
315+
for (const [scenario, before, after] of tests) {
316+
it(scenario, () => {
317+
const result = optimize(before);
318+
assert.deepEqual(result, after);
319+
});
320+
}
321+
});

0 commit comments

Comments
 (0)