diff --git a/src/lib/lambda/__tests__/bReduction.spec.js b/src/lib/lambda/__tests__/bReduction.spec.js index c055b3f..836b0fd 100644 --- a/src/lib/lambda/__tests__/bReduction.spec.js +++ b/src/lib/lambda/__tests__/bReduction.spec.js @@ -1,7 +1,6 @@ import { assert } from "chai"; import { bReduce } from "../operations"; import { purgeAstCache } from "../util"; -import { parseTerm } from "../parser"; describe("Beta Reductions", function () { it("Beta reduces a redex", function () { @@ -241,4 +240,42 @@ describe("Beta Reductions", function () { }; assert.deepEqual(purgeAstCache(bReduce(ast)), expected); }); + + it("can't replace a variable with itself.", () => { + const ast = { + type: "application", + left: { + type: "function", + argument: "ε₁", + body: { + type: "application", + left: { + type: "function", + argument: "a", + body: { + type: "function", + argument: "b", + body: { type: "variable", name: "b" }, + }, + }, + right: { type: "variable", name: "ε₁" }, + }, + }, + right: { type: "variable", name: "b" }, + }; + const expected = { + type: "application", + left: { + type: "function", + argument: "a", + body: { + type: "function", + argument: "b", + body: { type: "variable", name: "b" }, + }, + }, + right: { type: "variable", name: "b" }, + }; + assert.deepEqual(purgeAstCache(bReduce(ast)), expected); + }); });