diff --git a/example/test.js b/example/test.js index b97fd50..cf32b90 100644 --- a/example/test.js +++ b/example/test.js @@ -1,11 +1,7 @@ -import { assert, config as chaiConfig } from "chai"; -chaiConfig.truncateThreshold = 0; - -import * as LC from "@codewars/lambda-calculus"; -import { solution } from "./files.js"; // /workspace/files.js +import { assert, LC, getSolution } from "./lc-test.js"; LC.configure({ purity: "Let", numEncoding: "Church" }); -const { counter } = LC.compile(solution()); +const { counter } = LC.compile(getSolution()); const T = t => _ => t; const F = _ => f => f; diff --git a/workspace/lc-test.js b/workspace/lc-test.js index 3b5a4a4..2aac362 100644 --- a/workspace/lc-test.js +++ b/workspace/lc-test.js @@ -1,12 +1,15 @@ -// lc-test.js +import { readFileSync } from "fs"; + +export { assert, config } from "chai"; +export * as LC from "@codewars/lambda-calculus"; -import {readFileSync} from "fs"; const read = (path) => readFileSync(new URL(path, import.meta.url), {encoding: "utf8"}); +/** Return the contents of the solution file */ export const getSolution = () => read("./solution.lc"); -export const getPreloaded = () => read("./preloaded.lc"); -export const getPreloadedAndSolution = () => getPreloaded() + '\n' + getSolution() ; // this might as well check solution doesn't start with a continued line -export {assert,config} from "chai"; +/** Return the contents of the optional preloaded file */ +export const getPreloaded = () => read("./preloaded.lc"); -export * as LC from "@codewars/lambda-calculus"; \ No newline at end of file +/** Return the contents of the preloaded file and the solution file combined */ +export const getSolutionWithPreloaded = () => getPreloaded() + "\n" + getSolution(); diff --git a/workspace/package-lock.json b/workspace/package-lock.json index 5c89b44..043d67d 100644 --- a/workspace/package-lock.json +++ b/workspace/package-lock.json @@ -8,7 +8,7 @@ "name": "@codewars/lc-challenge", "version": "1.0.0", "dependencies": { - "@codewars/lambda-calculus": "^1.0.0-rc.3" + "@codewars/lambda-calculus": "^1.0.0-rc.4" }, "devDependencies": { "@codewars/mocha-reporter": "^1.0.0", @@ -17,9 +17,9 @@ } }, "node_modules/@codewars/lambda-calculus": { - "version": "1.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@codewars/lambda-calculus/-/lambda-calculus-1.0.0-rc.3.tgz", - "integrity": "sha512-kQPH45O325p/7ooOkuCJ4FLCOT9+Ou+BWewd/sOubEsrQjjVLS7jNNOC9ylzPumKhDmCmJu71Am/mPGAjAkioA==" + "version": "1.0.0-rc.4", + "resolved": "https://registry.npmjs.org/@codewars/lambda-calculus/-/lambda-calculus-1.0.0-rc.4.tgz", + "integrity": "sha512-/k9kVI/Scpgc3EjPJ7wU9fo0CwXKsFCVceNoXNn0wF/sKEwL+DxAPC5+0AMiClmynbs9TMbHEN3ct9/ic0XkUA==" }, "node_modules/@codewars/mocha-reporter": { "version": "1.0.0", @@ -1035,9 +1035,9 @@ }, "dependencies": { "@codewars/lambda-calculus": { - "version": "1.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@codewars/lambda-calculus/-/lambda-calculus-1.0.0-rc.3.tgz", - "integrity": "sha512-kQPH45O325p/7ooOkuCJ4FLCOT9+Ou+BWewd/sOubEsrQjjVLS7jNNOC9ylzPumKhDmCmJu71Am/mPGAjAkioA==" + "version": "1.0.0-rc.4", + "resolved": "https://registry.npmjs.org/@codewars/lambda-calculus/-/lambda-calculus-1.0.0-rc.4.tgz", + "integrity": "sha512-/k9kVI/Scpgc3EjPJ7wU9fo0CwXKsFCVceNoXNn0wF/sKEwL+DxAPC5+0AMiClmynbs9TMbHEN3ct9/ic0XkUA==" }, "@codewars/mocha-reporter": { "version": "1.0.0", diff --git a/workspace/package.json b/workspace/package.json index 51ffcf1..8fa7b39 100644 --- a/workspace/package.json +++ b/workspace/package.json @@ -11,7 +11,7 @@ "timeout": 0 }, "dependencies": { - "@codewars/lambda-calculus": "^1.0.0-rc.3" + "@codewars/lambda-calculus": "^1.0.0-rc.4" }, "devDependencies": { "@codewars/mocha-reporter": "^1.0.0", diff --git a/workspace/solution.lc b/workspace/solution.lc index fe748cf..96d26da 100644 --- a/workspace/solution.lc +++ b/workspace/solution.lc @@ -2,7 +2,6 @@ true = \ a b . a false = \ a b . b -%invalid = \a b . b zero = false succ = \ n f x . f (n f x) diff --git a/workspace/test.js b/workspace/test.js index d6f2620..e112641 100644 --- a/workspace/test.js +++ b/workspace/test.js @@ -1,19 +1,15 @@ -// test.js +import { assert, LC, getSolution } from "./lc-test.js"; -import * as LC from "./lc-test.js"; -LC.config.truncateThreshold = 0; -LC.configure({ purity: "Let", numEncoding: "Church" }); - -const {counter} = LC.compile(getSolution()); -const {toInt} = LC; +LC.configure({purity: "Let", numEncoding: "Church"}); +const { counter } = LC.compile(getSolution()); const T = t => _ => t; const F = _ => f => f; describe("counter", () => { it("fixed tests", () => { - assert.strictEqual(toInt(counter(T)(T)(T)(F)), 3); - assert.strictEqual(toInt(counter(T)(F)), 1); - assert.strictEqual(toInt(counter(T)(T)(T)(T)(T)(T)(T)(F)), 7); + assert.equal(counter(T)(T)(T)(F), 3); + assert.equal(counter(T)(F), 1); + assert.equal(counter(T)(T)(T)(T)(T)(T)(T)(F), 7); }); });