From cbc177d5d917c4f5344abbc144b37f0e12fcbf70 Mon Sep 17 00:00:00 2001 From: Evin Sellin Date: Sat, 20 Jan 2024 11:03:30 -0800 Subject: [PATCH] reproduce error --- src/lib/lambda/__tests__/bReduction.spec.js | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) 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); + }); });