Skip to content

Commit

Permalink
housekeeping: small edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Dierk Koenig committed Sep 12, 2023
1 parent 9189f92 commit 4757a82
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions docs/src/kolibri/lambda/churchTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TestSuite} from "../util/test.js";
import { TestSuite } from "../util/test.js";

import {
and,
Expand All @@ -16,48 +16,50 @@ import {
imp,
jsBool,
kite,
konst, LazyIf,
konst,
LazyIf,
Left,
maybe,
not,
or,
rec,
Right,
snd,
T, Tuple,
T,
Tuple,
uncurry,
xor,
toChurchBoolean,
toJsBool
} from "./church.js";

import { M, Th, Z } from "./ski.js";
import {Pair} from "./pair.js";
import {Just, Nothing} from "./maybe.js";
import { M, Th, Z } from "./ski.js";
import { Pair } from "./pair.js";
import { Just, Nothing } from "./maybe.js";

const churchSuite = TestSuite("lambda/church");

churchSuite.add("identity", assert => {

// noinspection EqualityComparisonWithCoercionJS
const weekEq = (a, b) => a == b;
const weakEq = (a, b) => a == b;

// identity
assert.is( id(0) , 0);
assert.is( id(1) , 1);
assert.is( id , id); // JS has function identity
assert.isTrue( weekEq("x => x", id)); // JS has weak function equivalence by string representation
assert.isTrue( weakEq("x => x", id)); // JS has weak function equivalence by string representation

// function equivalence
const other = x => x;
assert.isTrue( weekEq("x => x", other));
assert.isTrue( weakEq("x => x", other));

const alpha = y => y;
assert.isTrue( ! weekEq(alpha, id )); // JS has no alpha equivalence
assert.isTrue( ! weakEq(alpha, id )); // JS has no alpha equivalence

// in JS, a == b && a == c does not imply b == c
assert.isTrue( ! weekEq(id, other));
assert.isTrue( weekEq(id.toString(), other.toString()));
assert.isTrue( ! weakEq(id, other));
assert.isTrue( weakEq(id.toString(), other.toString()));
}
);

Expand Down

0 comments on commit 4757a82

Please sign in to comment.