From 169fefb600b3f0a636cea289ca530835817425c5 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Mon, 6 Jan 2020 18:52:18 -0800 Subject: [PATCH] yet more tests --- test/7.3.5.fs | 72 +++++++++++++++++++++++++++++++++++++++++ test/7.3.8-i.fs | 9 ++++++ test/7.3.9.fs | 7 +++- test/of816-words.fs | 13 ++++++++ test/test-manifest.yaml | 12 +++++-- 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 test/7.3.5.fs create mode 100644 test/of816-words.fs diff --git a/test/7.3.5.fs b/test/7.3.5.fs new file mode 100644 index 0000000..de4821b --- /dev/null +++ b/test/7.3.5.fs @@ -0,0 +1,72 @@ +testing 7.3.5.1 Numeric-base control + +t{ hex -> }t +t{ base @ -> 10 }t +t{ decimal base @ hex -> 0a }t +t{ octal base @ hex -> 08 }t + +testing 7.3.5.2 Numeric input + +hex + +t{ s" 123" $number -> 123 false }t +t{ s" $xyz" $number -> true }t + +t{ 0 s>d s" 456" >number nip -> 456 s>d 0 }t +t{ 0 s>d s" $xyz" >number nip -> 0 s>d 4 }t + +t{ 3a 30 do i 10 digit drop loop -> 0 1 2 3 4 5 6 7 8 9 }t +t{ 47 41 do i 10 digit drop loop -> a b c d e f }t +t{ 67 61 do i 10 digit drop loop -> a b c d e f }t +t{ 6a 67 do i 10 digit nip loop -> false false false }t + +t{ d# 10 -> 0a }t +decimal +t{ h# 10 hex -> 10 }t +hex +t{ o# 10 -> 08 }t + +testing 7.3.5.3 Numeric output + +\ the output must be examined by hand to completely verify +\ but if the subsequent privitives work, the chances are that +\ these work as well + +t{ 0 . 1 . -1 . -> }t +t{ 0 s. 1 s. -1 s. -> }t +t{ 0 u. 1 u. -1 u. -> }t \ 0 1 ffffffff +t{ -1 10 .r -> }t +t{ -1 10 u.r -> }t +t{ f .d -> }t +decimal +t{ 15 .h -> }t +hex +t{ 0 1 .s -> 0 1 }t +t{ base ? -> }t + +testing 7.3.5.4 Numeric output primitives + +hex + +: s= ( str len str len ) + 2 pick 2dup = if + drop swap comp 0= + else + 2drop 2drop false + then +; + +t{ 0 (.) s" 0" s= -> true }t +t{ -1 (.) s" -1" s= -> true }t +t{ 1 (.) s" 1" s= -> true }t + +t{ 0 (u.) s" 0" s= -> true }t +t{ -1 (u.) s" FFFFFFFF" s= -> true }t +t{ 1 (u.) s" 1" s= -> true }t + +T{ <# 41 HOLD 42 HOLD 0 0 #> S" BA" S= -> true }T +T{ <# -1 SIGN 0 SIGN -1 SIGN 0 0 #> S" --" S= -> true }T +T{ <# 1 0 # # #> S" 01" S= -> true }T +T{ <# 1 0 #S #> S" 1" S= -> true }T + +T{ <# 1 u#s u#> S" 1" S= -> true }T diff --git a/test/7.3.8-i.fs b/test/7.3.8-i.fs index 789eef7..5185d96 100644 --- a/test/7.3.8-i.fs +++ b/test/7.3.8-i.fs @@ -66,4 +66,13 @@ T{ 1 123 SWAP 0 DO I 4 > IF DROP 234 LEAVE THEN LOOP -> 123 }T T{ 5 123 SWAP 0 DO I 4 > IF DROP 234 LEAVE THEN LOOP -> 123 }T T{ 6 123 SWAP 0 DO I 4 > IF DROP 234 LEAVE THEN LOOP -> 234 }T +t{ 3 0 do unloop exit loop -> }t +t{ 3 0 do 3 0 do unloop unloop exit loop loop -> }t + t{ 1 0 do true ?leave false loop -> }t + +testing 7.3.8.6 Error handling - interpretation state + +t{ ' noop catch -> 0 }t +t{ clear ' drop catch -> -4 }t +t{ 123 ' throw catch nip -> 123 }t diff --git a/test/7.3.9.fs b/test/7.3.9.fs index f13051e..de4628b 100644 --- a/test/7.3.9.fs +++ b/test/7.3.9.fs @@ -79,7 +79,12 @@ testing 7.3.9.2 Dictionary commands testing 7.3.9.2.1 Data space allocation -\ tested in 7.3.3: here allot align c, w, l, , +\ mostly tested in 7.3.3: here allot align c, w, l, , + +t{ create da1 -> }t +t{ here align -> here }t \ OF816 has no alignment restrictions +t{ 0 c, here align -> here }t \ OF816 has no alignment restrictions +t{ here 2 cells allot 2 na+ -> here }t testing 7.3.9.2.2 Immediate words diff --git a/test/of816-words.fs b/test/of816-words.fs new file mode 100644 index 0000000..7afb92e --- /dev/null +++ b/test/of816-words.fs @@ -0,0 +1,13 @@ +testing OF816 words + +hex + +t{ 0 bsx -> 0 }t +t{ 7f bsx -> 7f }t +t{ 80 bsx -> -80 }t +t{ ff bsx -> -1 }t + +t{ 0 wsx -> 0 }t +t{ 7fff wsx -> 7fff }t +t{ 8000 wsx -> -8000 }t +t{ ffff wsx -> -1 }t diff --git a/test/test-manifest.yaml b/test/test-manifest.yaml index 315931a..176f0a3 100644 --- a/test/test-manifest.yaml +++ b/test/test-manifest.yaml @@ -30,10 +30,14 @@ - tester.fs - test-utils.fs - 7.3.3.fs -- name: 7.3.4 Text input +- name: 7.3.4 Text input and output load: - tester.fs - 7.3.4.fs +- name: 7.3.5 Numeric input and output + load: + - tester.fs + - 7.3.5.fs - name: 7.3.6 Comparison operators load: - tester.fs @@ -56,4 +60,8 @@ - name: 7.3.9 Forth dictionary load: - tester.fs - - 7.3.9.fs \ No newline at end of file + - 7.3.9.fs +- name: OF816 Words + load: + - tester.fs + - of816-words.fs \ No newline at end of file