aboutsummaryrefslogtreecommitdiff
path: root/forth/misc-tests.fs
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-02-14 13:40:07 -0500
committerChouser <chouser@n01se.net>2015-02-21 13:22:44 -0500
commit69972a8399efe4abb8567526e90262e131f90d26 (patch)
tree5e12e86da119a9c3f4372dab9e04777a746f90d0 /forth/misc-tests.fs
parent9da223a35a176d94fbb75cbcc1000871ff5aff0b (diff)
downloadmal-69972a8399efe4abb8567526e90262e131f90d26.tar.gz
mal-69972a8399efe4abb8567526e90262e131f90d26.zip
forth: Add step 3
Diffstat (limited to 'forth/misc-tests.fs')
-rw-r--r--forth/misc-tests.fs28
1 files changed, 22 insertions, 6 deletions
diff --git a/forth/misc-tests.fs b/forth/misc-tests.fs
index c428a12..ede5119 100644
--- a/forth/misc-tests.fs
+++ b/forth/misc-tests.fs
@@ -2,7 +2,7 @@ require printer.fs
\ === basic testing util === /
: test=
- 2dup = if
+ 2dup m= if
2drop
else
cr ." assert failed on line " sourceline# .
@@ -52,20 +52,38 @@ mal-nil
23 MalInt. mal-nil conj conj conj
pr-str s" (nil (20 (42) 10) 23)" str= -1 test=
+\ MalArray tests
+
+here 1 MalInt. , 2 MalInt. , 3 MalInt. , here>MalArray
+4 MalInt. swap conj
+5 MalInt. swap conj
+pr-str s" (5 4 1 2 3)" str= -1 test=
+
\ map tests
-s" one" MalString. s" one" MalString. mal= -1 test=
-s" one" MalString. s" x" MalString. mal= 0 test=
+s" one" MalString. s" one" MalString. test=
+s" one" MalString. s" x" MalString. m= 0 test=
+
+MalMap/Empty
+1000 MalInt. 1100 rot assoc
+2000 MalInt. 2100 rot assoc
+3000 MalInt. 3100 rot assoc
+
+dup 99 2000 MalInt. rot get 2100 test=
+dup 99 4000 MalInt. rot get 99 test=
+drop
MalMap/Empty
s" one" MalString. s" first" MalString. rot assoc
s" two" MalString. s" second" MalString. rot assoc
s" three" MalString. s" third" MalString. rot assoc
-dup 99 s" two" MalString. rot get s" second" MalString. mal= -1 test=
+dup 99 s" two" MalString. rot get s" second" MalString. test=
dup 99 s" none" MalString. rot get 99 test=
drop
+99 MalInt. 10 MalInt. MalMap/Empty get 99 MalInt. test=
+
\ eval tests
require step2_eval.fs
@@ -74,8 +92,6 @@ mal-nil
1 MalInt. swap conj
2 MalInt. swap conj
3 MalInt. swap conj
-~~
mal-eval
-~~
bye