-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
31 lines (29 loc) · 905 Bytes
/
test.ts
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
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import Solution from "./solution.ts";
Object.defineProperty(globalThis, "isTest", {
value: true,
writable: false,
configurable: false,
enumerable: false,
});
for await (const file of Deno.readDir(".")) {
if (file.isFile && file.name.match(/\d{2}\.ts/)) {
const { default: sol }: { default: Solution<unknown, unknown> } =
await import(`./${file.name}`);
sol.filename = file.name;
sol.reader = (name, second) => {
if (second) {
try {
return Deno.readTextFileSync(`data/${name}_test2.txt`);
// deno-lint-ignore no-empty
} catch {}
}
return Deno.readTextFileSync(`data/${name}_test.txt`);
};
sol.reporter = (name, result, expect) =>
Deno.test(name, () => {
assertEquals(result, expect);
});
sol.execute();
}
}