1 USING: accessors arrays compiler.units kernel kernel.private
2 math math.constants math.private math.integers.private sequences
3 strings tools.test words continuations sequences.private
4 hashtables.private byte-arrays system random layouts vectors
5 sbufs strings.private slots.private alien math.order
6 alien.accessors alien.c-types alien.data alien.syntax alien.strings
7 namespaces libc io.encodings.ascii classes compiler ;
9 IN: compiler.tests.intrinsics
11 ! Make sure that intrinsic ops compile to correct code.
12 [ ] [ 1 [ drop ] compile-call ] unit-test
13 [ ] [ 1 2 [ 2drop ] compile-call ] unit-test
14 [ ] [ 1 2 3 [ 3drop ] compile-call ] unit-test
15 [ 1 1 ] [ 1 [ dup ] compile-call ] unit-test
16 [ 1 2 1 2 ] [ 1 2 [ 2dup ] compile-call ] unit-test
17 [ 1 2 3 1 2 3 ] [ 1 2 3 [ 3dup ] compile-call ] unit-test
18 [ 2 3 1 ] [ 1 2 3 [ rot ] compile-call ] unit-test
19 [ 3 1 2 ] [ 1 2 3 [ -rot ] compile-call ] unit-test
20 [ 1 1 2 ] [ 1 2 [ dupd ] compile-call ] unit-test
21 [ 2 1 3 ] [ 1 2 3 [ swapd ] compile-call ] unit-test
22 [ 2 ] [ 1 2 [ nip ] compile-call ] unit-test
23 [ 3 ] [ 1 2 3 [ 2nip ] compile-call ] unit-test
24 [ 2 1 2 ] [ 1 2 [ tuck ] compile-call ] unit-test
25 [ 1 2 1 ] [ 1 2 [ over ] compile-call ] unit-test
26 [ 1 2 3 1 ] [ 1 2 3 [ pick ] compile-call ] unit-test
27 [ 2 1 ] [ 1 2 [ swap ] compile-call ] unit-test
29 [ 1 ] [ { 1 2 } [ 2 slot ] compile-call ] unit-test
30 [ 1 ] [ [ { 1 2 } 2 slot ] compile-call ] unit-test
32 [ { f f } ] [ 2 f <array> ] unit-test
34 [ 3 ] [ 3 1 2 2array [ { array } declare [ 2 set-slot ] keep ] compile-call first ] unit-test
35 [ 3 ] [ 3 1 2 [ 2array [ 2 set-slot ] keep ] compile-call first ] unit-test
36 [ 3 ] [ [ 3 1 2 2array [ 2 set-slot ] keep ] compile-call first ] unit-test
37 [ 3 ] [ 3 1 2 2array [ [ 3 set-slot ] keep ] compile-call second ] unit-test
38 [ 3 ] [ 3 1 2 [ 2array [ 3 set-slot ] keep ] compile-call second ] unit-test
39 [ 3 ] [ [ 3 1 2 2array [ 3 set-slot ] keep ] compile-call second ] unit-test
41 ! Write barrier hits on the wrong value were causing segfaults
42 [ -3 ] [ -3 1 2 [ 2array [ 3 set-slot ] keep ] compile-call second ] unit-test
44 [ CHAR: a ] [ 0 "abc" [ string-nth ] compile-call ] unit-test
45 [ CHAR: a ] [ 0 [ "abc" string-nth ] compile-call ] unit-test
46 [ CHAR: a ] [ [ 0 "abc" string-nth ] compile-call ] unit-test
47 [ CHAR: b ] [ 1 "abc" [ string-nth ] compile-call ] unit-test
48 [ CHAR: b ] [ 1 [ "abc" string-nth ] compile-call ] unit-test
49 [ CHAR: b ] [ [ 1 "abc" string-nth ] compile-call ] unit-test
51 [ HEX: 123456 ] [ 0 "\u123456bc" [ string-nth ] compile-call ] unit-test
52 [ HEX: 123456 ] [ 0 [ "\u123456bc" string-nth ] compile-call ] unit-test
53 [ HEX: 123456 ] [ [ 0 "\u123456bc" string-nth ] compile-call ] unit-test
54 [ HEX: 123456 ] [ 1 "a\u123456c" [ string-nth ] compile-call ] unit-test
55 [ HEX: 123456 ] [ 1 [ "a\u123456c" string-nth ] compile-call ] unit-test
56 [ HEX: 123456 ] [ [ 1 "a\u123456c" string-nth ] compile-call ] unit-test
58 [ ] [ [ 0 getenv ] compile-call drop ] unit-test
59 [ ] [ 1 getenv [ 1 setenv ] compile-call ] unit-test
61 [ ] [ 1 [ drop ] compile-call ] unit-test
62 [ ] [ [ 1 drop ] compile-call ] unit-test
63 [ ] [ [ 1 2 2drop ] compile-call ] unit-test
64 [ ] [ 1 [ 2 2drop ] compile-call ] unit-test
65 [ ] [ 1 2 [ 2drop ] compile-call ] unit-test
66 [ 2 1 ] [ [ 1 2 swap ] compile-call ] unit-test
67 [ 2 1 ] [ 1 [ 2 swap ] compile-call ] unit-test
68 [ 2 1 ] [ 1 2 [ swap ] compile-call ] unit-test
69 [ 1 1 ] [ 1 [ dup ] compile-call ] unit-test
70 [ 1 1 ] [ [ 1 dup ] compile-call ] unit-test
71 [ 1 2 1 ] [ [ 1 2 over ] compile-call ] unit-test
72 [ 1 2 1 ] [ 1 [ 2 over ] compile-call ] unit-test
73 [ 1 2 1 ] [ 1 2 [ over ] compile-call ] unit-test
74 [ 1 2 3 1 ] [ [ 1 2 3 pick ] compile-call ] unit-test
75 [ 1 2 3 1 ] [ 1 [ 2 3 pick ] compile-call ] unit-test
76 [ 1 2 3 1 ] [ 1 2 [ 3 pick ] compile-call ] unit-test
77 [ 1 2 3 1 ] [ 1 2 3 [ pick ] compile-call ] unit-test
78 [ 1 1 2 ] [ [ 1 2 dupd ] compile-call ] unit-test
79 [ 1 1 2 ] [ 1 [ 2 dupd ] compile-call ] unit-test
80 [ 1 1 2 ] [ 1 2 [ dupd ] compile-call ] unit-test
81 [ 2 ] [ [ 1 2 nip ] compile-call ] unit-test
82 [ 2 ] [ 1 [ 2 nip ] compile-call ] unit-test
83 [ 2 ] [ 1 2 [ nip ] compile-call ] unit-test
85 [ 2 1 "hi" ] [ 1 2 [ swap "hi" ] compile-call ] unit-test
87 [ 4 ] [ 12 7 [ fixnum-bitand ] compile-call ] unit-test
88 [ 4 ] [ 12 [ 7 fixnum-bitand ] compile-call ] unit-test
89 [ 4 ] [ [ 12 7 fixnum-bitand ] compile-call ] unit-test
91 [ 15 ] [ 12 7 [ fixnum-bitor ] compile-call ] unit-test
92 [ 15 ] [ 12 [ 7 fixnum-bitor ] compile-call ] unit-test
93 [ 15 ] [ [ 12 7 fixnum-bitor ] compile-call ] unit-test
95 [ 11 ] [ 12 7 [ fixnum-bitxor ] compile-call ] unit-test
96 [ 11 ] [ 12 [ 7 fixnum-bitxor ] compile-call ] unit-test
97 [ 11 ] [ [ 12 7 fixnum-bitxor ] compile-call ] unit-test
99 [ f ] [ 12 7 [ fixnum< [ t ] [ f ] if ] compile-call ] unit-test
100 [ f ] [ 12 [ 7 fixnum< [ t ] [ f ] if ] compile-call ] unit-test
101 [ f ] [ [ 12 7 fixnum< [ t ] [ f ] if ] compile-call ] unit-test
102 [ f ] [ [ 12 12 fixnum< [ t ] [ f ] if ] compile-call ] unit-test
103 [ f ] [ 12 12 [ fixnum< [ t ] [ f ] if ] compile-call ] unit-test
105 [ t ] [ 12 70 [ fixnum< [ t ] [ f ] if ] compile-call ] unit-test
106 [ t ] [ 12 [ 70 fixnum< [ t ] [ f ] if ] compile-call ] unit-test
107 [ t ] [ [ 12 70 fixnum< [ t ] [ f ] if ] compile-call ] unit-test
109 [ f ] [ 12 7 [ fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
110 [ f ] [ 12 [ 7 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
111 [ f ] [ [ 12 7 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
112 [ t ] [ [ 12 12 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
113 [ t ] [ [ 12 12 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
114 [ t ] [ 12 12 [ fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
116 [ t ] [ 12 70 [ fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
117 [ t ] [ 12 [ 70 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
118 [ t ] [ [ 12 70 fixnum<= [ t ] [ f ] if ] compile-call ] unit-test
120 [ t ] [ 12 7 [ fixnum> [ t ] [ f ] if ] compile-call ] unit-test
121 [ t ] [ 12 [ 7 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
122 [ t ] [ [ 12 7 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
123 [ f ] [ [ 12 12 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
124 [ f ] [ [ 12 12 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
125 [ f ] [ 12 12 [ fixnum> [ t ] [ f ] if ] compile-call ] unit-test
127 [ f ] [ 12 70 [ fixnum> [ t ] [ f ] if ] compile-call ] unit-test
128 [ f ] [ 12 [ 70 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
129 [ f ] [ [ 12 70 fixnum> [ t ] [ f ] if ] compile-call ] unit-test
131 [ t ] [ 12 7 [ fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
132 [ t ] [ 12 [ 7 fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
133 [ t ] [ [ 12 7 fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
134 [ t ] [ [ 12 12 fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
135 [ t ] [ 12 12 [ fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
137 [ f ] [ 12 70 [ fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
138 [ f ] [ 12 [ 70 fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
139 [ f ] [ [ 12 70 fixnum>= [ t ] [ f ] if ] compile-call ] unit-test
141 [ f ] [ 1 2 [ eq? [ t ] [ f ] if ] compile-call ] unit-test
142 [ f ] [ 1 [ 2 eq? [ t ] [ f ] if ] compile-call ] unit-test
143 [ f ] [ [ 1 2 eq? [ t ] [ f ] if ] compile-call ] unit-test
144 [ t ] [ 3 3 [ eq? [ t ] [ f ] if ] compile-call ] unit-test
145 [ t ] [ 3 [ 3 eq? [ t ] [ f ] if ] compile-call ] unit-test
146 [ t ] [ [ 3 3 eq? [ t ] [ f ] if ] compile-call ] unit-test
148 [ -1 ] [ 0 [ fixnum-bitnot ] compile-call ] unit-test
149 [ -1 ] [ [ 0 fixnum-bitnot ] compile-call ] unit-test
151 [ 3 ] [ 13 10 [ fixnum-mod ] compile-call ] unit-test
152 [ 3 ] [ 13 [ 10 fixnum-mod ] compile-call ] unit-test
153 [ 3 ] [ [ 13 10 fixnum-mod ] compile-call ] unit-test
154 [ -3 ] [ -13 10 [ fixnum-mod ] compile-call ] unit-test
155 [ -3 ] [ -13 [ 10 fixnum-mod ] compile-call ] unit-test
156 [ -3 ] [ [ -13 10 fixnum-mod ] compile-call ] unit-test
158 [ 2 ] [ 4 2 [ fixnum/i ] compile-call ] unit-test
159 [ 2 ] [ 4 [ 2 fixnum/i ] compile-call ] unit-test
160 [ -2 ] [ 4 [ -2 fixnum/i ] compile-call ] unit-test
161 [ 3 1 ] [ 10 3 [ fixnum/mod ] compile-call ] unit-test
163 [ 2 ] [ 4 2 [ fixnum/i-fast ] compile-call ] unit-test
164 [ 2 ] [ 4 [ 2 fixnum/i-fast ] compile-call ] unit-test
165 [ -2 ] [ 4 [ -2 fixnum/i-fast ] compile-call ] unit-test
166 [ 3 1 ] [ 10 3 [ fixnum/mod-fast ] compile-call ] unit-test
168 [ 4 ] [ 1 3 [ fixnum+ ] compile-call ] unit-test
169 [ 4 ] [ 1 [ 3 fixnum+ ] compile-call ] unit-test
170 [ 4 ] [ [ 1 3 fixnum+ ] compile-call ] unit-test
172 [ 4 ] [ 1 3 [ fixnum+fast ] compile-call ] unit-test
173 [ 4 ] [ 1 [ 3 fixnum+fast ] compile-call ] unit-test
174 [ 4 ] [ [ 1 3 fixnum+fast ] compile-call ] unit-test
176 [ -2 ] [ 1 3 [ fixnum-fast ] compile-call ] unit-test
177 [ -2 ] [ 1 [ 3 fixnum-fast ] compile-call ] unit-test
178 [ -2 ] [ [ 1 3 fixnum-fast ] compile-call ] unit-test
180 [ 30001 ] [ 1 [ 30000 fixnum+fast ] compile-call ] unit-test
182 [ 6 ] [ 2 3 [ fixnum*fast ] compile-call ] unit-test
183 [ 6 ] [ 2 [ 3 fixnum*fast ] compile-call ] unit-test
184 [ 6 ] [ [ 2 3 fixnum*fast ] compile-call ] unit-test
185 [ -6 ] [ 2 -3 [ fixnum*fast ] compile-call ] unit-test
186 [ -6 ] [ 2 [ -3 fixnum*fast ] compile-call ] unit-test
187 [ -6 ] [ [ 2 -3 fixnum*fast ] compile-call ] unit-test
189 [ 6 ] [ 2 3 [ fixnum* ] compile-call ] unit-test
190 [ 6 ] [ 2 [ 3 fixnum* ] compile-call ] unit-test
191 [ 6 ] [ [ 2 3 fixnum* ] compile-call ] unit-test
192 [ -6 ] [ 2 -3 [ fixnum* ] compile-call ] unit-test
193 [ -6 ] [ 2 [ -3 fixnum* ] compile-call ] unit-test
194 [ -6 ] [ [ 2 -3 fixnum* ] compile-call ] unit-test
196 [ 5 ] [ 1 2 [ eq? [ 3 ] [ 5 ] if ] compile-call ] unit-test
197 [ 3 ] [ 2 2 [ eq? [ 3 ] [ 5 ] if ] compile-call ] unit-test
198 [ 3 ] [ 1 2 [ fixnum< [ 3 ] [ 5 ] if ] compile-call ] unit-test
199 [ 5 ] [ 2 2 [ fixnum< [ 3 ] [ 5 ] if ] compile-call ] unit-test
201 [ 8 ] [ 1 3 [ fixnum-shift ] compile-call ] unit-test
202 [ 8 ] [ 1 [ 3 fixnum-shift ] compile-call ] unit-test
203 [ 8 ] [ [ 1 3 fixnum-shift ] compile-call ] unit-test
204 [ -8 ] [ -1 3 [ fixnum-shift ] compile-call ] unit-test
205 [ -8 ] [ -1 [ 3 fixnum-shift ] compile-call ] unit-test
206 [ -8 ] [ [ -1 3 fixnum-shift ] compile-call ] unit-test
208 [ 2 ] [ 8 -2 [ fixnum-shift ] compile-call ] unit-test
209 [ 2 ] [ 8 [ -2 fixnum-shift ] compile-call ] unit-test
211 [ 0 ] [ [ 123 -64 fixnum-shift ] compile-call ] unit-test
212 [ 0 ] [ 123 -64 [ fixnum-shift ] compile-call ] unit-test
213 [ -1 ] [ [ -123 -64 fixnum-shift ] compile-call ] unit-test
214 [ -1 ] [ -123 -64 [ fixnum-shift ] compile-call ] unit-test
216 [ 4294967296 ] [ 1 32 [ fixnum-shift ] compile-call ] unit-test
217 [ 4294967296 ] [ 1 [ 32 fixnum-shift ] compile-call ] unit-test
218 [ 4294967296 ] [ 1 [ 16 fixnum-shift 16 fixnum-shift ] compile-call ] unit-test
219 [ -4294967296 ] [ -1 32 [ fixnum-shift ] compile-call ] unit-test
220 [ -4294967296 ] [ -1 [ 32 fixnum-shift ] compile-call ] unit-test
221 [ -4294967296 ] [ -1 [ 16 fixnum-shift 16 fixnum-shift ] compile-call ] unit-test
223 [ 8 ] [ 1 3 [ fixnum-shift-fast ] compile-call ] unit-test
224 [ 8 ] [ 1 3 [ 15 bitand fixnum-shift-fast ] compile-call ] unit-test
225 [ 8 ] [ 1 [ 3 fixnum-shift-fast ] compile-call ] unit-test
226 [ 8 ] [ [ 1 3 fixnum-shift-fast ] compile-call ] unit-test
227 [ -8 ] [ -1 3 [ fixnum-shift-fast ] compile-call ] unit-test
228 [ -8 ] [ -1 3 [ 15 bitand fixnum-shift-fast ] compile-call ] unit-test
229 [ -8 ] [ -1 [ 3 fixnum-shift-fast ] compile-call ] unit-test
230 [ -8 ] [ [ -1 3 fixnum-shift-fast ] compile-call ] unit-test
232 [ 2 ] [ 8 -2 [ fixnum-shift-fast ] compile-call ] unit-test
233 [ 2 ] [ 8 2 [ 15 bitand neg fixnum-shift-fast ] compile-call ] unit-test
234 [ 2 ] [ 8 [ -2 fixnum-shift-fast ] compile-call ] unit-test
236 [ 4294967296 ] [ 1 32 [ fixnum-shift ] compile-call ] unit-test
237 [ 4294967296 ] [ 1 [ 32 fixnum-shift ] compile-call ] unit-test
238 [ 4294967296 ] [ 1 [ 16 fixnum-shift 16 fixnum-shift ] compile-call ] unit-test
239 [ -4294967296 ] [ -1 32 [ fixnum-shift ] compile-call ] unit-test
240 [ -4294967296 ] [ -1 [ 32 fixnum-shift ] compile-call ] unit-test
241 [ -4294967296 ] [ -1 [ 16 fixnum-shift 16 fixnum-shift ] compile-call ] unit-test
243 [ HEX: 10000000 ] [ HEX: 1000000 HEX: 10 [ fixnum* ] compile-call ] unit-test
244 [ HEX: 10000000 ] [ HEX: -10000000 >fixnum [ 0 swap fixnum- ] compile-call ] unit-test
245 [ HEX: 10000000 ] [ HEX: -fffffff >fixnum [ 1 swap fixnum- ] compile-call ] unit-test
247 [ t ] [ 1 27 fixnum-shift dup [ fixnum+ ] compile-call 1 28 fixnum-shift = ] unit-test
248 [ -268435457 ] [ 1 28 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
250 [ t ] [ 1 20 shift 1 20 shift [ fixnum* ] compile-call 1 40 shift = ] unit-test
251 [ t ] [ 1 20 shift neg 1 20 shift [ fixnum* ] compile-call 1 40 shift neg = ] unit-test
252 [ t ] [ 1 20 shift neg 1 20 shift neg [ fixnum* ] compile-call 1 40 shift = ] unit-test
253 [ -351382792 ] [ -43922849 [ 3 fixnum-shift ] compile-call ] unit-test
255 [ 268435456 ] [ -268435456 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
257 [ 268435456 0 ] [ -268435456 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
259 [ t ] [ f [ f eq? ] compile-call ] unit-test
263 HEX: 4200 [ HEX: 7fff fixnum-bitand 13 fixnum-shift-fast 112 23 fixnum-shift-fast fixnum+fast ]
270 100001 f <array> 3 100000 pick set-nth
271 [ 100000 swap array-nth ] compile-call
274 [ 2 ] [ 2 4 [ fixnum-min ] compile-call ] unit-test
275 [ 2 ] [ 4 2 [ fixnum-min ] compile-call ] unit-test
276 [ 4 ] [ 2 4 [ fixnum-max ] compile-call ] unit-test
277 [ 4 ] [ 4 2 [ fixnum-max ] compile-call ] unit-test
278 [ -2 ] [ -2 -4 [ fixnum-max ] compile-call ] unit-test
279 [ -2 ] [ -4 -2 [ fixnum-max ] compile-call ] unit-test
280 [ -4 ] [ -2 -4 [ fixnum-min ] compile-call ] unit-test
281 [ -4 ] [ -4 -2 [ fixnum-min ] compile-call ] unit-test
285 [ t ] [ 1 59 fixnum-shift dup [ fixnum+ ] compile-call 1 60 fixnum-shift = ] unit-test
286 [ -1152921504606846977 ] [ 1 60 shift neg >fixnum [ -1 fixnum+ ] compile-call ] unit-test
288 [ t ] [ 1 40 shift 1 40 shift [ fixnum* ] compile-call 1 80 shift = ] unit-test
289 [ t ] [ 1 40 shift neg 1 40 shift [ fixnum* ] compile-call 1 80 shift neg = ] unit-test
290 [ t ] [ 1 40 shift neg 1 40 shift neg [ fixnum* ] compile-call 1 80 shift = ] unit-test
291 [ t ] [ 1 30 shift neg 1 50 shift neg [ fixnum* ] compile-call 1 80 shift = ] unit-test
292 [ t ] [ 1 50 shift neg 1 30 shift neg [ fixnum* ] compile-call 1 80 shift = ] unit-test
294 [ 18446744073709551616 ] [ 1 64 [ fixnum-shift ] compile-call ] unit-test
295 [ 18446744073709551616 ] [ 1 [ 64 fixnum-shift ] compile-call ] unit-test
296 [ 18446744073709551616 ] [ 1 [ 32 fixnum-shift 32 fixnum-shift ] compile-call ] unit-test
297 [ -18446744073709551616 ] [ -1 64 [ fixnum-shift ] compile-call ] unit-test
298 [ -18446744073709551616 ] [ -1 [ 64 fixnum-shift ] compile-call ] unit-test
299 [ -18446744073709551616 ] [ -1 [ 32 fixnum-shift 32 fixnum-shift ] compile-call ] unit-test
301 [ 1152921504606846976 ] [ -1152921504606846976 >fixnum -1 [ fixnum/i ] compile-call ] unit-test
303 [ 1152921504606846976 0 ] [ -1152921504606846976 >fixnum -1 [ fixnum/mod ] compile-call ] unit-test
305 [ -268435457 ] [ 28 2^ [ fixnum-bitnot ] compile-call ] unit-test
308 ! Some randomized tests
309 : compiled-fixnum* ( a b -- c ) fixnum* ;
313 32 random-bits >fixnum 32 random-bits >fixnum
315 [ fixnum* ] 2keep compiled-fixnum* =
316 [ 2drop ] [ "Oops" throw ] if
320 : compiled-fixnum>bignum ( a -- b ) fixnum>bignum ;
322 [ bignum ] [ 0 compiled-fixnum>bignum class ] unit-test
326 32 random-bits >fixnum
327 dup [ fixnum>bignum ] keep compiled-fixnum>bignum =
328 [ drop ] [ "Oops" throw ] if
332 : compiled-bignum>fixnum ( a -- b ) bignum>fixnum ;
336 5 random [ drop 32 random-bits ] map product >bignum
337 dup [ bignum>fixnum ] keep compiled-bignum>fixnum =
338 [ drop ] [ "Oops" throw ] if
342 ! Test overflow check removal
344 most-positive-fixnum 100 - >fixnum
346 [ [ fixnum+ ] compile-call [ bignum>fixnum ] compile-call ] 2keep
347 [ fixnum+ >fixnum ] compile-call
352 most-negative-fixnum 100 + >fixnum
354 [ [ fixnum+ ] compile-call [ bignum>fixnum ] compile-call ] 2keep
355 [ fixnum+ >fixnum ] compile-call
360 most-negative-fixnum 100 + >fixnum
362 [ [ fixnum- ] compile-call [ bignum>fixnum ] compile-call ] 2keep
363 [ fixnum- >fixnum ] compile-call
367 ! Test inline allocators
369 [ 3 1 <array> ] compile-call
373 [ 3 <byte-array> ] compile-call
377 [ 500 <byte-array> length ] compile-call
381 1 2 [ complex boa ] compile-call
382 dup real-part swap imaginary-part
386 1 2 [ ratio boa ] compile-call dup numerator swap denominator
389 [ \ + ] [ \ + [ <wrapper> ] compile-call ] unit-test
392 [ 5 <byte-array> ] compile-call
396 { 1 2 3 } 2 [ vector boa ] compile-call
400 "hello world" 5 [ sbuf boa ] compile-call
404 3 [ + ] [ curry ] compile-call
408 [ 3 ] [ B{ 1 2 3 4 5 } 2 [ alien-unsigned-1 ] compile-call ] unit-test
409 [ 3 ] [ [ B{ 1 2 3 4 5 } 2 alien-unsigned-1 ] compile-call ] unit-test
410 [ 3 ] [ B{ 1 2 3 4 5 } 2 [ { byte-array fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
411 [ 3 ] [ B{ 1 2 3 4 5 } 2 [ { c-ptr fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
413 [ ] [ B{ 1 2 3 4 5 } malloc-byte-array "b" set ] unit-test
414 [ t ] [ "b" get >boolean ] unit-test
417 [ 3 ] [ "b" get 2 [ alien-unsigned-1 ] compile-call ] unit-test
418 [ 3 ] [ "b" get [ { alien } declare 2 alien-unsigned-1 ] compile-call ] unit-test
419 [ 3 ] [ "b" get 2 [ { simple-alien fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
420 [ 3 ] [ "b" get 2 [ { c-ptr fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
422 [ ] [ "b" get free ] unit-test
425 [ ] [ "hello world" ascii malloc-string "s" set ] unit-test
428 [ "hello world" ] [ "s" get <void*> [ { byte-array } declare *void* ] compile-call ascii alien>string ] unit-test
429 [ "hello world" ] [ "s" get <void*> [ { c-ptr } declare *void* ] compile-call ascii alien>string ] unit-test
431 [ ] [ "s" get free ] unit-test
434 [ ALIEN: 1234 ] [ ALIEN: 1234 [ { alien } declare <void*> ] compile-call *void* ] unit-test
435 [ ALIEN: 1234 ] [ ALIEN: 1234 [ { c-ptr } declare <void*> ] compile-call *void* ] unit-test
436 [ f ] [ f [ { POSTPONE: f } declare <void*> ] compile-call *void* ] unit-test
438 [ 252 ] [ B{ 1 2 3 -4 5 } 3 [ { byte-array fixnum } declare alien-unsigned-1 ] compile-call ] unit-test
439 [ -4 ] [ B{ 1 2 3 -4 5 } 3 [ { byte-array fixnum } declare alien-signed-1 ] compile-call ] unit-test
441 [ -100 ] [ -100 <char> [ { byte-array } declare *char ] compile-call ] unit-test
442 [ 156 ] [ -100 <uchar> [ { byte-array } declare *uchar ] compile-call ] unit-test
444 [ -100 ] [ -100 \ <char> def>> [ { fixnum } declare ] prepend compile-call *char ] unit-test
445 [ 156 ] [ -100 \ <uchar> def>> [ { fixnum } declare ] prepend compile-call *uchar ] unit-test
447 [ -1000 ] [ -1000 <short> [ { byte-array } declare *short ] compile-call ] unit-test
448 [ 64536 ] [ -1000 <ushort> [ { byte-array } declare *ushort ] compile-call ] unit-test
450 [ -1000 ] [ -1000 \ <short> def>> [ { fixnum } declare ] prepend compile-call *short ] unit-test
451 [ 64536 ] [ -1000 \ <ushort> def>> [ { fixnum } declare ] prepend compile-call *ushort ] unit-test
453 [ -100000 ] [ -100000 <int> [ { byte-array } declare *int ] compile-call ] unit-test
454 [ 4294867296 ] [ -100000 <uint> [ { byte-array } declare *uint ] compile-call ] unit-test
456 [ -100000 ] [ -100000 \ <int> def>> [ { fixnum } declare ] prepend compile-call *int ] unit-test
457 [ 4294867296 ] [ -100000 \ <uint> def>> [ { fixnum } declare ] prepend compile-call *uint ] unit-test
459 [ t ] [ pi pi <double> *double = ] unit-test
461 [ t ] [ pi <double> [ { byte-array } declare *double ] compile-call pi = ] unit-test
464 [ t ] [ pi 4 <byte-array> [ [ { float byte-array } declare 0 set-alien-float ] compile-call ] keep *float pi - -0.001 0.001 between? ] unit-test
465 [ t ] [ pi <float> [ { byte-array } declare *float ] compile-call pi - -0.001 0.001 between? ] unit-test
467 [ t ] [ pi 8 <byte-array> [ [ { float byte-array } declare 0 set-alien-double ] compile-call ] keep *double pi = ] unit-test
470 2 B{ 1 2 3 4 5 6 } <displaced-alien> [
471 { alien } declare 1 alien-unsigned-1
476 HEX: 123 [ <alien> ] compile-call
480 HEX: 123 [ { fixnum } declare <alien> ] compile-call
484 [ HEX: 123 <alien> ] compile-call
488 0 [ <alien> ] compile-call
492 0 [ { fixnum } declare <alien> ] compile-call
496 [ 0 <alien> ] compile-call
500 0 ALIEN: 321 [ <displaced-alien> ] compile-call
504 0 ALIEN: 321 [ { fixnum c-ptr } declare <displaced-alien> ] compile-call
508 ALIEN: 321 [ 0 swap <displaced-alien> ] compile-call
512 2 B{ 0 1 2 3 4 } <displaced-alien>
513 [ 1 swap <displaced-alien> ] compile-call
518 2 B{ 0 1 2 3 4 } <displaced-alien>
519 [ 1 swap { c-ptr } declare <displaced-alien> ] compile-call
523 [ ALIEN: 1234 ALIEN: 2234 ] [
526 [ HEX: 1000 swap <displaced-alien> ]
527 [ HEX: 2000 swap <displaced-alien> ] bi
532 B{ 0 0 0 0 } [ { byte-array } declare <void*> ] compile-call
536 B{ 0 0 0 0 } [ { c-ptr } declare <void*> ] compile-call
544 { [ 4444 ] [ 444 ] [ 44 ] [ 4 ] } dispatch
550 8 -3 [ fixnum-shift-fast ] compile-call
554 16 -3 [ fixnum-shift-fast ] compile-call
558 16 [ -3 fixnum-shift-fast ] compile-call
562 1 3 [ fixnum-shift-fast ] compile-call
566 1 [ 3 fixnum-shift-fast ] compile-call
569 TUPLE: alien-accessor-regression { b byte-array } { i fixnum } ;
572 B{ 0 0 } 1 alien-accessor-regression boa
574 { alien-accessor-regression } declare
575 [ i>> ] [ b>> ] bi over set-alien-unsigned-1
580 : mutable-value-bug-1 ( a b -- c )
582 { tuple } declare 1 slot
587 [ t ] [ f B{ } mutable-value-bug-1 byte-array type-number = ] unit-test
589 : mutable-value-bug-2 ( a b -- c )
593 { tuple } declare 1 slot
596 [ t ] [ t B{ } mutable-value-bug-2 byte-array type-number = ] unit-test