-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
tests.txt
126 lines (86 loc) · 3.18 KB
/
tests.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
__ simple operator => [ 3 ]
1 2 +
__ alts => [ { 10 | 15 | 14 | 21 } ]
2 3 | 5 7 | *
__ pushl/popr => [ [] 3 ]
1 [2+] pushl popr
__ sharing test => [ [ 4 ] [ 2 ] ]
[1+] dup [3] swap . swap [1] swap .
__ sharing test
[[3 +]] dup popr 1 swap pushl
__ dup alt
1 2 | dup
__ compose alt
[3] [2*] [2-] | .
__ compose dup
[1] [dup] .
__ pushl sharing
[3+] dup 1 swap pushl
[dup] dup pushl
1 [dup] dup . pushl popr
__ [dup pushl popr] dup pushl popr
__ [dup pushl popr swap drop] dup pushl popr swap drop
__ infinite [1]'s
[dup pushl popr swap 1] dup pushl popr drop popr popr popr
__ [[] 1] [! drop dup 0 swap pushl pushl] [0 == ! drop 0 force [] pushl pushl] | . popr swap drop popr
[1 2 | ] popr
__ [[[! force drop dup [0] pushl swap pushl popr swap drop] [0 == ! force drop [0] force pushl] | . popr swap drop] 1] [! force drop dup [0] pushl swap pushl popr swap drop] [0 == ! force drop [0] force pushl] | . popr swap drop
[[1 2 |][3 4|] |] popr popr
[[[5]]] [[[4]] [[3] [2 1 |]|]|]| popr swap drop popr swap drop popr swap drop
__ [[[! force 1- ' [dup] dip12 pushl swap pushl popr swap drop] [0 == ! force drop [0] force pushl] | . popr swap drop] 1] [! force 1- ' [dup] dip12 pushl swap pushl popr swap drop] [0 == ! force drop [0] force pushl] | . popr swap drop
__ [[[! 1- [] force pushl [dup] dip12 pushl swap pushl popr swap drop] [dup 0 == ! force drop [] force pushl force pushl] | . popr swap drop cut] 5] [! 1- [] force pushl [dup] dip12 pushl swap pushl popr swap drop] [dup 0 == ! force drop [] force pushl force pushl] | . popr swap drop cut
1 0 | dup
1 [1- dup 0 > !] [1+ dup 0 > !] | pushl popr
[0 |] dup 4 swap pushl popr swap drop swap 3 swap pushl popr swap drop +
[1] [3] | popr pushr popr
[0 1 |] dup popr swap drop swap popr swap drop
__ [1 [swap 1+ swap force dup pushl pushl popr swap drop]] [dup] . popr . popr
__ [5 [swap [! 1-] [0 == ! 0 force swap drop] | pushl head swap force dup pushl pushl head]] [dup] . popr . popr
__ [1 [swap ! 1- swap force dup pushl pushl head] [swap 0 == ! 1- force swap] || ] [dup] . popr . popr
__ [100 [swap ! cut 1- swap force dup pushl pushl popr swap popr swap drop swap] [swap 0 == ! cut 1- force swap] || ] [dup] . popr . [swap] . head cut
__ =loop 6 [dup 0 > swap 5- loop swap !] [dup 0 <= !] | pushl
False True | dup !
1 [dup swap drop] pushl popr
__ type mismatch test
0 [True =:=] [0 ==] | pushl popr swap drop
__ test assert with > 2 alts
1 2 3 | | dup 3 < !
[1] 2 pushr [3] 4 pushr .
__ test integer -> float promotion
1 2.3 +f
__ numeric parsing
-0xf0e1
0xf0e1
1e3
1.2e3
1.2
__ otherwise
1 0 / 40 2 + otherwise
1 0 / 2 3 | otherwise
1 2 | 3 otherwise
1 2 otherwise 3 otherwise
__ strings
"a" "b" ++
"a" "a" =s
"a" "b" =s
42 ->str
"42" <-str
"a, b" ", " strsplit
"========>" "---------------good" ++
__ IO
__ IO 5 read "Hello " swap ++ "\n" ++ write
__ World
__ [] [] | popr
[A] False! [B] . popr swap drop
[1] id [2] id [3] . .
__ [1] id [2] . dup .
__ [1] [. 2] id [3 B] . dup . .
__ arrays
Array 3 42 write_array Array 3 10 write_array swap 3 read_array swap drop swap 3 read_array swap drop
Array 3 read_array 0 swap unless
__ fix me
2 3 | 5 7 | * dup 15 == !
__ comma
[[1,2],3,[4,5]]
__ number parsing
-0.005 -5e-3 5e-3 5e3 -0xa 0xA 0644 42