Skip to content

Commit 7f97b49

Browse files
committed
Add numEql assertion
1 parent 8b9e8d7 commit 7f97b49

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

workspace/lc-test.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { readFileSync } from "fs";
22

3-
export { assert, config } from "chai";
4-
export * as LC from "@codewars/lambda-calculus";
3+
import { assert, config } from "chai";
4+
import * as LC from "../src/lambda-calculus.js";
5+
6+
export { assert, config, LC };
57

68
const read = (path) => readFileSync(new URL(path, import.meta.url), {encoding: "utf8"});
79

@@ -13,3 +15,16 @@ export const getPreloaded = () => read("./preloaded.lc");
1315

1416
/** Return the contents of the preloaded file and the solution file combined */
1517
export const getSolutionWithPreloaded = () => getPreloaded() + "\n" + getSolution();
18+
19+
20+
/** Custom assertions */
21+
22+
function numEql(got, exp, msg) {
23+
if ( got?.term && got?.env ) got = LC.toInt(got);
24+
if ( exp?.term && exp?.env ) exp = LC.toInt(exp);
25+
return this.equal(got, exp, msg);
26+
}
27+
28+
Object.assign(assert, {
29+
numEql
30+
});

0 commit comments

Comments
 (0)