-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.mjs
39 lines (37 loc) · 1.25 KB
/
test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import fs from "fs";
import assert from "assert";
import {years} from "./tree.mjs";
describe("AoC solutions", () =>
years.forEach(year =>
describe(year.name, () =>
year.days.forEach(day =>
describe(day.name, () => {
if (day.disabled != true) {
if (day.answers.part1 != undefined) {
it("Part 1", () =>
import(day.path + "/code.mjs").then(dayCode =>
fs.promises.readFile(day.path + "/testInput.txt").then(input =>
(new dayCode.default()).solve(1, input.toString(), false).then(answer => {
assert.equal(answer, day.answers.part1);
})
)
)
);
}
if (day.answers.part2 != undefined) {
it("Part 2", () =>
import(day.path + "/code.mjs").then(dayCode =>
fs.promises.readFile(day.path + "/testInput.txt").then(input =>
(new dayCode.default()).solve(2, input.toString(), false).then(answer => {
assert.equal(answer, day.answers.part2);
})
)
)
);
}
}
})
)
)
)
);