blob: 7b5d5dbf8ade29691e3082fff7420f2ffd3c7043 (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
(define-library (csc linker-test)
(import (scheme base)
(only (csc format)
sprintf)
(only (csc hash-map)
alist->map
hash-bytevector
make-comparer
make-map)
(only (csc list)
all)
(only (csc testing)
assert-equal
test)
(csc linker))
(begin
(test link-labels
(assert-equal
'((jmp (const 3))
(jmp (const 2))
(jmp (const 1))
(jmp (const 1)))
(link
'(((label 0)
(jmp (label 1))
(label 1)
(jmp (label 0))
(label init)
(jmp (label 0)))))))
(test link-labels-are-unique-per-program
(assert-equal
'((jmp (const 2))
(jmp (const 1))
(jmp (const 1))
(jmp (const 5))
(jmp (const 4))
(jmp (const 4)))
(link
'(((label 0)
(jmp (label 0))
(label init)
(jmp (label 0)))
((label 0)
(jmp (label 0))
(label init)
(jmp (label 0)))))))
(test link-globals
(assert-equal
'((jmp (const 1))
(peek (local 0) (const 10)))
(link
'(((label init)
(peek (local 0) (global cons (csc based)))))
(alist->map compare-globals '(((global cons (csc based)) . 10))))))))
|