-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheap_test.ts
More file actions
30 lines (26 loc) · 836 Bytes
/
Copy pathheap_test.ts
File metadata and controls
30 lines (26 loc) · 836 Bytes
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
import { assertEquals } from "jsr:@std/assert/assert-equals";
import { Heap } from "./heap.ts";
import { callFn } from "./exec.ts";
import { makeBoolean, makeNumber } from "./ast.ts";
Deno.test(function getSymbol() {
const heap = new Heap();
assertEquals(
callFn(heap.getSymbol("==")!, makeNumber(1), makeNumber(1)),
makeBoolean(true),
);
});
Deno.test(function setSymbol() {
const heap = new Heap();
heap.setSymbol("myVal", makeNumber(1));
assertEquals(heap.getSymbol("myVal"), makeNumber(1));
// Check that this still looks up builtins
assertEquals(
callFn(heap.getSymbol("==")!, makeNumber(1), makeNumber(1)),
makeBoolean(true),
);
});
Deno.test(function shadowSymbol() {
const heap = new Heap();
heap.setSymbol("==", makeNumber(1));
assertEquals(heap.getSymbol("=="), makeNumber(1));
});