forth: Added lists, ints, symbols for step 1
[jackhill/mal.git] / forth / misc-tests.fs
CommitLineData
59038a10
C
1require printer.fs
2
3\ === basic testing util === /
4: test=
5 2dup = if
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=
23
2410 new-array
251 swap 0 5 array-insert
262 swap 1 7 array-insert
273 swap 3 12 array-insert
284 swap 4 15 array-insert
295 swap 5 20 array-insert
30
31dup 0 cells + @ 5 test=
32dup 1 cells + @ 7 test=
33dup 2 cells + @ 10 test=
34dup 3 cells + @ 12 test=
35dup 4 cells + @ 15 test=
36dup 5 cells + @ 20 test=
37
38
39\ MalType tests
40
41MalList new MalList new = 0 test=
42
43MalList new dup MalList/car 5 swap ! MalList/car @ 5 test=
44
45
46\ Protocol tests
47
48mal-nil
4942 MalInt. mal-nil conj
5010 MalInt. mal-nil conj conj
5120 MalInt. swap conj
5223 MalInt. mal-nil conj conj conj
53pr-str s" (nil (20 (42) 10) 23)" str= -1 test=