mirror of
https://github.com/louisrubet/rpn
synced 2025-01-29 20:34:21 +01:00
#2: new test sheets
This commit is contained in:
parent
4d394e845e
commit
d7fe2ce743
3 changed files with 263 additions and 0 deletions
87
test/entry.txt
Normal file
87
test/entry.txt
Normal file
|
@ -0,0 +1,87 @@
|
|||
## ENTRY TEST
|
||||
default
|
||||
erase
|
||||
|
||||
# real decimal
|
||||
1
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
|
||||
drop
|
||||
2.345
|
||||
-> stack should be 2.345
|
||||
|
||||
erase
|
||||
1 2.345 3 4.9
|
||||
-> stack size should be 4
|
||||
-> stack should be 1, 2.345, 3, 4.9
|
||||
|
||||
# real hex
|
||||
erase
|
||||
0x1234
|
||||
-> stack should be 4660
|
||||
|
||||
drop
|
||||
0x10.10
|
||||
-> stack should be 16.0625
|
||||
|
||||
# real binary
|
||||
erase
|
||||
0b11001100
|
||||
-> stack should be 204
|
||||
|
||||
erase
|
||||
0b11001100.1101
|
||||
-> stack should be 204.8125
|
||||
|
||||
# real inf, nan
|
||||
erase
|
||||
inf
|
||||
@inf@
|
||||
+inf
|
||||
+@inf@
|
||||
-inf
|
||||
-@inf@
|
||||
nan
|
||||
@nan@
|
||||
-> stack should be inf, inf, inf,-inf, -inf, nan, nan
|
||||
|
||||
# binary decimal
|
||||
erase
|
||||
#123d
|
||||
-> stack size should be 1
|
||||
-> stack should be 123 d
|
||||
|
||||
# binary hex
|
||||
erase
|
||||
#123h
|
||||
-> stack size should be 1
|
||||
-> stack should be 291 d
|
||||
|
||||
# binary binary
|
||||
erase
|
||||
#1101b
|
||||
-> stack size should be 1
|
||||
-> stack should be 13 d
|
||||
|
||||
# symbol
|
||||
erase
|
||||
'test'
|
||||
-> stack size should be 1
|
||||
-> stack should be 'test'
|
||||
|
||||
erase
|
||||
'test
|
||||
-> stack size should be 1
|
||||
-> stack should be 'test'
|
||||
|
||||
# string
|
||||
erase
|
||||
"test string"
|
||||
-> stack size should be 1
|
||||
-> stack should be "test string"
|
||||
|
||||
erase
|
||||
"test string
|
||||
-> stack size should be 1
|
||||
-> stack should be "test string"
|
93
test/rpn-test.txt
Normal file
93
test/rpn-test.txt
Normal file
|
@ -0,0 +1,93 @@
|
|||
## 2 ## TEST
|
||||
# and (1)
|
||||
and
|
||||
-> error should be 2
|
||||
1 and
|
||||
-> error should be 2
|
||||
drop
|
||||
|
||||
# and (2)
|
||||
0 0 and
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
||||
|
||||
# and (3)
|
||||
1 0 and
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
||||
|
||||
# and (4)
|
||||
0 1 and
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
||||
|
||||
# and (5)
|
||||
1 1 and
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# or (1)
|
||||
or
|
||||
-> error should be 2
|
||||
1 or
|
||||
-> error should be 2
|
||||
drop
|
||||
|
||||
# or (2)
|
||||
0 0 or
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
||||
|
||||
# or (3)
|
||||
0 1 or
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# or (4)
|
||||
1 0 or
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# or (5)
|
||||
1 1 or
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# xor (1)
|
||||
xor
|
||||
-> error should be 2
|
||||
1 xor
|
||||
-> error should be 2
|
||||
drop
|
||||
|
||||
# xor (2)
|
||||
0 0 xor
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
||||
|
||||
# xor (3)
|
||||
0 1 xor
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# xor (4)
|
||||
1 0 xor
|
||||
-> stack size should be 1
|
||||
-> stack should be 1
|
||||
drop
|
||||
|
||||
# xor (5)
|
||||
1 1 xor
|
||||
-> stack size should be 1
|
||||
-> stack should be 0
|
||||
drop
|
83
test/stack.txt
Normal file
83
test/stack.txt
Normal file
|
@ -0,0 +1,83 @@
|
|||
## STACK TEST
|
||||
# test entry 1
|
||||
1
|
||||
-> stack size should be 1
|
||||
|
||||
# test entry 2
|
||||
2 3
|
||||
-> stack size should be 3
|
||||
-> stack should be 3, 2, 1
|
||||
|
||||
# test drop
|
||||
drop
|
||||
-> stack size should be 2
|
||||
|
||||
# test drop2
|
||||
drop2
|
||||
-> stack size should be 0
|
||||
|
||||
# test drop error
|
||||
drop
|
||||
-> error should be 2
|
||||
|
||||
# test drop2 error
|
||||
drop2
|
||||
-> error should be 2
|
||||
|
||||
# test drop2 error
|
||||
1 drop2
|
||||
-> error should be 2
|
||||
drop
|
||||
|
||||
# test symbol entry 1
|
||||
1 '2'
|
||||
-> stack size should be 2
|
||||
-> stack should be '2', 1
|
||||
drop2
|
||||
|
||||
# test symbol entry 2
|
||||
1 '2
|
||||
-> stack size should be 2
|
||||
-> stack should be '2', 1
|
||||
drop2
|
||||
|
||||
# test symbol entry 3
|
||||
''
|
||||
-> stack should be ''
|
||||
drop
|
||||
|
||||
# test symbol entry 4
|
||||
'
|
||||
-> stack should be ''
|
||||
drop
|
||||
|
||||
# test dup
|
||||
1 dup
|
||||
-> stack size should be 2
|
||||
-> stack should be 1, 1
|
||||
|
||||
# test dup2
|
||||
drop 2 dup2
|
||||
-> stack size should be 4
|
||||
-> stack should be 2, 1, 2, 1
|
||||
drop2 drop2
|
||||
|
||||
# test rot
|
||||
1 2 3 rot
|
||||
-> stack size should be 3
|
||||
-> stack should be 1, 3, 2
|
||||
|
||||
# test depth
|
||||
depth
|
||||
-> stack size should be 4
|
||||
-> stack should be 3, 1, 3, 2
|
||||
drop2 drop2
|
||||
|
||||
# test pick
|
||||
1 2 3 4 2 pick
|
||||
-> stack size should be 5
|
||||
-> stack should be 3, 4, 3, 2, 1
|
||||
|
||||
# test erase
|
||||
erase
|
||||
-> stack size should be 0
|
Loading…
Add table
Reference in a new issue