mirror of
https://github.com/louisrubet/rpn
synced 2024-12-30 10:23:32 +01:00
386 lines
5.5 KiB
Text
386 lines
5.5 KiB
Text
## BRANCH
|
|
|
|
# if then else end (1)
|
|
1 if then 'ok' end
|
|
-> stack should be 'ok'
|
|
erase
|
|
|
|
# if then else end (2)
|
|
1 if 'before' then 'ok' end
|
|
-> stack should be 'before', 'ok'
|
|
erase
|
|
|
|
# if then else end (3)
|
|
0 if then 'ok' end
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# if then else end (4)
|
|
0 if then 'ok' end
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# if then else end (5)
|
|
1 if then 'ok' else 'KO' end
|
|
-> stack should be 'ok'
|
|
erase
|
|
|
|
# if then else end (6)
|
|
1 if then 'ok' 'dokey' else 'KO' end
|
|
-> stack should be 'ok', 'dokey'
|
|
erase
|
|
|
|
# if then else end (7)
|
|
0 if then 'ok' else 'KO' end
|
|
-> stack should be 'KO'
|
|
erase
|
|
|
|
# if then else end - error case (1)
|
|
if then end
|
|
-> error should be 2
|
|
erase
|
|
|
|
# if then else end - error case (2)
|
|
0 if then
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (3)
|
|
0 if end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (4)
|
|
0 if end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (5)
|
|
then
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (6)
|
|
1 if
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (7)
|
|
else
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (8)
|
|
end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# if then else end - error case (9)
|
|
"1" if then end
|
|
-> error should be 3
|
|
erase
|
|
|
|
# ift (1)
|
|
1 'ok' ift
|
|
-> stack should be 'ok'
|
|
erase
|
|
|
|
# ift (2)
|
|
0 'ok' ift
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# ift (3)
|
|
'ok' ift
|
|
-> error should be 2
|
|
-> stack size should be 1
|
|
erase
|
|
|
|
# ift (4)
|
|
ift
|
|
-> error should be 2
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# ifte (1)
|
|
1 'ok' 'nok' ifte
|
|
-> stack should be 'ok'
|
|
erase
|
|
|
|
# ifte (2)
|
|
0 'ok' 'nok' ifte
|
|
-> stack should be 'nok'
|
|
erase
|
|
|
|
# ifte (3)
|
|
'ok' 'nok' ifte
|
|
-> error should be 2
|
|
-> stack size should be 2
|
|
erase
|
|
|
|
# ifte (4)
|
|
'nok' ifte
|
|
-> error should be 2
|
|
-> stack size should be 1
|
|
erase
|
|
|
|
# ifte (5)
|
|
ifte
|
|
-> error should be 2
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# start next (1)
|
|
1 2 start 0 next
|
|
-> stack should be 0, 0
|
|
erase
|
|
|
|
# start next (2)
|
|
2 1 start 0 next
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# start next (3)
|
|
-2 -1 start 0 next
|
|
-> stack should be 0, 0
|
|
erase
|
|
|
|
# start next (4)
|
|
-1 -2 start 0 next
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# start next (5)
|
|
1 1 start 0 next
|
|
-> stack should be 0
|
|
erase
|
|
|
|
# start next - error case (1)
|
|
1 start next
|
|
->error should be 2
|
|
erase
|
|
|
|
# start next - error case (2)
|
|
start next
|
|
->error should be 2
|
|
erase
|
|
|
|
# start next - error case (3)
|
|
start
|
|
->error should be 11
|
|
erase
|
|
|
|
# start next - error case (4)
|
|
next
|
|
->error should be 11
|
|
erase
|
|
|
|
# start next - error case (5)
|
|
"1" 2 start next
|
|
->error should be 3
|
|
erase
|
|
|
|
# start next - error case (5)
|
|
1 "2" start next
|
|
->error should be 3
|
|
erase
|
|
|
|
# for next (1)
|
|
23 27 for i i next
|
|
-> stack should be 23, 24, 25, 26, 27
|
|
erase
|
|
|
|
# for next (2)
|
|
1 1 for i i next
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# for next (3)
|
|
27 23 for i i next
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# for next (4)
|
|
-2 -1 for i i next
|
|
-> stack should be -2, -1
|
|
erase
|
|
|
|
# for next (5)
|
|
-1 -2 for i i next
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# for next - error case (1)
|
|
1 for i i next
|
|
-> error should be 2
|
|
erase
|
|
|
|
# for next - error case (2)
|
|
for i i next
|
|
-> error should be 2
|
|
erase
|
|
|
|
# for next - error case (3)
|
|
"1" 2 for i i next
|
|
-> error should be 3
|
|
erase
|
|
|
|
# for next - error case (4)
|
|
1 "2" for i i next
|
|
-> error should be 3
|
|
erase
|
|
|
|
# for next - error case (5)
|
|
1 2 for i i
|
|
-> error should be 11
|
|
erase
|
|
|
|
# for next - error case (6)
|
|
for
|
|
-> error should be 11
|
|
erase
|
|
|
|
# for step (1)
|
|
23 27 for i i 1 step
|
|
-> stack should be 23, 24, 25, 26, 27
|
|
erase
|
|
|
|
# for step (2)
|
|
0 1 for i i 0.25 step
|
|
-> stack should be 0, 0.25, 0.5, 0.75, 1
|
|
erase
|
|
|
|
# for step (3)
|
|
-1 0 for i i 0.25 step
|
|
-> stack should be -1, -0.75, -0.5, -0.25, 0
|
|
erase
|
|
|
|
# for step (4)
|
|
0 -1 for i i 0.25 step
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# for step (5)
|
|
0 -1 for i i -0.25 step
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# for step - error case (1)
|
|
0 1 for i i "0.5" step
|
|
-> error should be 3
|
|
erase
|
|
|
|
# for step - error case (2)
|
|
step
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti (1)
|
|
do 'ok' unti 1 end
|
|
-> stack should be 'ok'
|
|
erase
|
|
|
|
# do..unti (2)
|
|
do unti 1 end
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# do..unti (3)
|
|
1 'a' sto do a unti a 0 > end
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# do..unti (4)
|
|
1 'a' sto do a 'a' 1 sto+ unti a 3 > end
|
|
-> stack should be 1, 2, 3
|
|
erase
|
|
|
|
# do..unti (5)
|
|
"" 0 'a' sto do 'a' 1 sto+ 0 a for b b ->str + next unti a 3 > end
|
|
-> stack should be "01012012301234"
|
|
erase
|
|
|
|
# do..unti error case (1)
|
|
do
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (2)
|
|
do 8 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (3)
|
|
unti
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (4)
|
|
do 3 unti
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (5)
|
|
unti 1 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (6)
|
|
do 3 repeat 8 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# do..unti error case (7)
|
|
do 3 until 8 until 9 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat (1)
|
|
while 0 repeat ok end
|
|
-> stack size should be 0
|
|
erase
|
|
|
|
# while..repeat (2)
|
|
2 while dup 0.1 > repeat dup 2 / end
|
|
-> stack should be 2, 1, 0.5, 0.25, 0.125, 0.0625
|
|
erase
|
|
|
|
# while..repeat (3)
|
|
"" 0 'a' sto while a 3 < repeat 'a' 1 sto+ 0 a for b b ->str + next end
|
|
-> stack should be "010120123"
|
|
erase
|
|
|
|
# while..repeat error case (1)
|
|
while
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (2)
|
|
while 3 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (3)
|
|
repeat
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (4)
|
|
while 1 repeat
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (5)
|
|
repeat 1 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (6)
|
|
while 3 repeat 8 repeat 9 end
|
|
-> error should be 11
|
|
erase
|
|
|
|
# while..repeat error case (7)
|
|
while 3 until 8 end
|
|
-> error should be 11
|
|
erase
|