plsql: add dockerfile. Lots of cleanup/renaming.
[jackhill/mal.git] / forth / misc-tests.fs
1 require printer.fs
2
3 \ === basic testing util === /
4 : test=
5 2dup m= 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
13 create za 2 , 6 , 7 , 10 , 15 , 80 , 81 ,
14
15 7 za 2 array-find -1 test= 0 test=
16 7 za 6 array-find -1 test= 1 test=
17 7 za 10 array-find -1 test= 3 test=
18 7 za 81 array-find -1 test= 6 test=
19 7 za 12 array-find 0 test= 4 test=
20 7 za 8 array-find 0 test= 3 test=
21 7 za 100 array-find 0 test= 7 test=
22 7 za 1 array-find 0 test= 0 test=
23 6 za 81 array-find 0 test= 6 test=
24
25 10 new-array
26 1 swap 0 5 array-insert
27 2 swap 1 7 array-insert
28 3 swap 3 12 array-insert
29 4 swap 4 15 array-insert
30 5 swap 5 20 array-insert
31
32 dup 0 cells + @ 5 test=
33 dup 1 cells + @ 7 test=
34 dup 2 cells + @ 10 test=
35 dup 3 cells + @ 12 test=
36 dup 4 cells + @ 15 test=
37 dup 5 cells + @ 20 test=
38
39
40 \ Protocol tests
41
42 : t1
43 mal-nil
44 42 MalInt. mal-nil conj
45 10 MalInt. mal-nil conj conj
46 20 MalInt. swap conj
47 23 MalInt. mal-nil conj conj conj
48 pr-str s" (nil (20 (42) 10) 23)" str= -1 test=
49
50 1500 MalInt. 1500 MalInt. test=
51
52 \ MalList tests
53
54 here 1 MalInt. , 2 MalInt. , 3 MalInt. , here>MalList
55 4 MalInt. swap conj
56 5 MalInt. swap conj
57 pr-str s" (5 4 1 2 3)" str= -1 test=
58
59 \ map tests
60
61 s" one" MalString. s" one" MalString. test=
62 s" one" MalString. s" x" MalString. m= 0 test=
63
64 MalMap/Empty
65 1000 MalInt. 1100 rot assoc
66 2000 MalInt. 2100 rot assoc
67 3000 MalInt. 3100 rot assoc
68
69 dup 99 2000 MalInt. rot get 2100 test=
70 dup 99 4000 MalInt. rot get 99 test=
71 drop
72
73 MalMap/Empty
74 s" one" MalString. s" first" MalString. rot assoc
75 s" two" MalString. s" second" MalString. rot assoc
76 s" three" MalString. s" third" MalString. rot assoc
77
78 dup 99 s" two" MalString. rot get s" second" MalString. test=
79 dup 99 s" none" MalString. rot get 99 test=
80 drop
81
82 99 MalInt. 10 MalInt. MalMap/Empty get 99 MalInt. test=
83
84 ;
85 t1
86
87 \ eval tests
88
89 require step2_eval.fs
90
91 : t2
92 mal-nil
93 1 MalInt. swap conj
94 2 MalInt. swap conj
95 3 MalInt. swap conj
96 mal-eval
97 ;
98 t2
99
100 bye