Skip to content

Commit aa39028

Browse files
committed
Add lc-test.js
1 parent 476403f commit aa39028

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN set -ex; \
77

88
COPY --chown=codewarrior:codewarrior workspace/package.json /workspace/package.json
99
COPY --chown=codewarrior:codewarrior workspace/package-lock.json /workspace/package-lock.json
10-
COPY --chown=codewarrior:codewarrior workspace/files.js /workspace/files.js
10+
COPY --chown=codewarrior:codewarrior workspace/lc-test.js /workspace/lc-test.js
1111

1212
USER codewarrior
1313
WORKDIR /workspace

example/test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { assert, config as chaiConfig } from "chai";
2-
chaiConfig.truncateThreshold = 0;
3-
4-
import * as LC from "@codewars/lambda-calculus";
5-
import { solution } from "./files.js"; // /workspace/files.js
1+
import { assert, LC, solution } from "./lc-test.js";
62

73
LC.configure({ purity: "Let", numEncoding: "Church" });
84
const { counter } = LC.compile(solution());
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { readFileSync } from "fs";
22

3+
import { assert, config as chaiConfig } from "chai";
4+
chaiConfig.truncateThreshold = 0;
5+
export { assert };
6+
export * as LC from "@codewars/lambda-calculus";
7+
38
const read = (path) => readFileSync(new URL(path, import.meta.url), {encoding: "utf8"});
49

510
/** Return the contents of the solution file */

workspace/solution.lc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
true = \ a b . a
44
false = \ a b . b
5-
%invalid = \a b . b
65

76
zero = false
87
succ = \ n f x . f (n f x)

workspace/test.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
import { assert, config as chaiConfig } from "chai";
2-
chaiConfig.truncateThreshold = 0;
1+
import { assert, LC, solution } from "./lc-test.js";
32

4-
import * as LC from "@codewars/lambda-calculus";
5-
import { solution } from "./files.js"; // /workspace/files.js
6-
7-
LC.config.purity = "Let";
8-
LC.config.numEncoding = "Church";
9-
const toInt = LC.toIntWith(LC.config);
3+
LC.configure({purity: "Let", numEncoding: "Church"});
104
const { counter } = LC.compile(solution());
115

126
const T = t => _ => t;
137
const F = _ => f => f;
148

159
describe("counter", () => {
1610
it("fixed tests", () => {
17-
assert.strictEqual(toInt(counter(T)(T)(T)(F)), 3);
18-
assert.strictEqual(toInt(counter(T)(F)), 1);
19-
assert.strictEqual(toInt(counter(T)(T)(T)(T)(T)(T)(T)(F)), 7);
11+
assert.equal(counter(T)(T)(T)(F), 3);
12+
assert.equal(counter(T)(F), 1);
13+
assert.equal(counter(T)(T)(T)(T)(T)(T)(T)(F), 7);
2014
});
2115
});

0 commit comments

Comments
 (0)