DISABLE FDs (REMOVE ME).
[jackhill/mal.git] / forth / misc-tests.fs
CommitLineData
59038a10
C
1require printer.fs
2
3\ === basic testing util === /
4: test=
69972a83 5 2dup m= if
59038a10
C
6 2drop
7 else
8 cr ." assert failed on line " sourceline# .
9 swap cr ." | got " . cr ." | expected " . cr
10 endif ;
11
12\ array function tests
13create za 2 , 6 , 7 , 10 , 15 , 80 , 81 ,
14
157 za 2 array-find -1 test= 0 test=
167 za 6 array-find -1 test= 1 test=
177 za 10 array-find -1 test= 3 test=
187 za 81 array-find -1 test= 6 test=
197 za 12 array-find 0 test= 4 test=
207 za 8 array-find 0 test= 3 test=
217 za 100 array-find 0 test= 7 test=
227 za 1 array-find 0 test= 0 test=
b254151c 236 za 81 array-find 0 test= 6 test=
59038a10
C
24
2510 new-array
261 swap 0 5 array-insert
272 swap 1 7 array-insert
283 swap 3 12 array-insert
294 swap 4 15 array-insert
305 swap 5 20 array-insert
31
32dup 0 cells + @ 5 test=
33dup 1 cells + @ 7 test=
34dup 2 cells + @ 10 test=
35dup 3 cells + @ 12 test=
36dup 4 cells + @ 15 test=
37dup 5 cells + @ 20 test=
38
39
59038a10
C
40\ Protocol tests
41
975126be 42: t1
59038a10
C
43mal-nil
4442 MalInt. mal-nil conj
4510 MalInt. mal-nil conj conj
4620 MalInt. swap conj
4723 MalInt. mal-nil conj conj conj
48pr-str s" (nil (20 (42) 10) 23)" str= -1 test=
9da223a3 49
c05d35e8
C
501500 MalInt. 1500 MalInt. test=
51
52\ MalList tests
69972a83 53
c05d35e8 54here 1 MalInt. , 2 MalInt. , 3 MalInt. , here>MalList
69972a83
C
554 MalInt. swap conj
565 MalInt. swap conj
57pr-str s" (5 4 1 2 3)" str= -1 test=
58
9da223a3
C
59\ map tests
60
69972a83
C
61s" one" MalString. s" one" MalString. test=
62s" one" MalString. s" x" MalString. m= 0 test=
63
64MalMap/Empty
651000 MalInt. 1100 rot assoc
662000 MalInt. 2100 rot assoc
673000 MalInt. 3100 rot assoc
68
69dup 99 2000 MalInt. rot get 2100 test=
70dup 99 4000 MalInt. rot get 99 test=
71drop
9da223a3
C
72
73MalMap/Empty
74s" one" MalString. s" first" MalString. rot assoc
75s" two" MalString. s" second" MalString. rot assoc
76s" three" MalString. s" third" MalString. rot assoc
77
69972a83 78dup 99 s" two" MalString. rot get s" second" MalString. test=
9da223a3
C
79dup 99 s" none" MalString. rot get 99 test=
80drop
81
69972a83
C
8299 MalInt. 10 MalInt. MalMap/Empty get 99 MalInt. test=
83
975126be
C
84;
85t1
86
9da223a3
C
87\ eval tests
88
89require step2_eval.fs
90
975126be 91: t2
9da223a3
C
92mal-nil
93 1 MalInt. swap conj
94 2 MalInt. swap conj
95 3 MalInt. swap conj
9da223a3 96mal-eval
975126be
C
97;
98t2
9da223a3
C
99
100bye