mirror of
https://github.com/mgcaret/of816.git
synced 2024-12-26 13:31:54 +00:00
yet more tests
This commit is contained in:
parent
a6ee722f04
commit
169fefb600
72
test/7.3.5.fs
Normal file
72
test/7.3.5.fs
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
13
test/of816-words.fs
Normal file
13
test/of816-words.fs
Normal file
@ -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
|
@ -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
|
||||
- 7.3.9.fs
|
||||
- name: OF816 Words
|
||||
load:
|
||||
- tester.fs
|
||||
- of816-words.fs
|
Loading…
Reference in New Issue
Block a user