-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.ts
46 lines (40 loc) · 1.04 KB
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { unify, atom, variable, functor, NO } from ".";
test("unify", () => {
expect(unify(atom("x"), atom("x"))).toEqual({});
expect(unify(atom("x"), atom("y"))).toBeNull();
expect(unify(variable("x"), variable("x"))).toEqual({});
expect(unify(variable("x"), variable("y"))).toEqual({
x: variable("y"),
y: variable("x"),
});
expect(
unify(
functor("f", [atom("x"), atom("y")]),
functor("f", [atom("x"), atom("y")])
)
).toEqual({});
expect(
unify(
functor("f", [atom("x"), atom("y")]),
functor("g", [atom("x"), atom("y")])
)
).toEqual(NO);
expect(
unify(
functor("f", [variable("X"), atom(2)]),
functor("f", [atom(1), atom(2)])
)
).toEqual({ X: atom(1) });
expect(
unify(
functor("f", [variable("X"), variable("X")]),
functor("f", [atom(1), atom(2)])
)
).toEqual(NO);
expect(
unify(
functor("f", [variable("X"), variable("X")]),
functor("f", [functor("g", [variable("Y")]), functor("g", [atom(2)])])
)
).toEqual(NO);
});