compiler.tests.alien: tests to make sure #1021 stays dead

db4
Björn Lindqvist 2014-11-12 08:13:17 +01:00 committed by John Benediktsson
parent 8489dd9be6
commit 18d7be2c05
1 changed files with 49 additions and 10 deletions

View File

@ -1,13 +1,11 @@
USING: accessors alien alien.c-types alien.libraries USING: accessors alien alien.c-types alien.complex alien.data alien.libraries
alien.syntax arrays classes.struct combinators alien.syntax arrays byte-arrays classes classes.struct combinators
compiler continuations destructors effects generalizations io combinators.extras compiler compiler.test concurrency.promises continuations
io.backend io.pathnames io.streams.string kernel destructors effects generalizations io io.backend io.pathnames
math memory namespaces namespaces.private parser io.streams.string kernel kernel.private libc layouts math math.bitwise
quotations sequences specialized-arrays stack-checker math.private memory namespaces namespaces.private random parser quotations
stack-checker.errors system threads tools.test words sequences slots.private specialized-arrays stack-checker stack-checker.errors
alien.complex concurrency.promises alien.data system threads tools.test words ;
byte-arrays classes compiler.test libc layouts
math.bitwise ;
FROM: alien.c-types => float short ; FROM: alien.c-types => float short ;
SPECIALIZED-ARRAY: float SPECIALIZED-ARRAY: float
SPECIALIZED-ARRAY: char SPECIALIZED-ARRAY: char
@ -918,3 +916,44 @@ FUNCTION: ulonglong-pair ffi_test_63 ( ) ;
S{ ulonglong-pair { a 0xabcdefabcdefabcd } { b 0x1234567891234567 } } S{ ulonglong-pair { a 0xabcdefabcdefabcd } { b 0x1234567891234567 } }
} [ ffi_test_63 ] unit-test } [ ffi_test_63 ] unit-test
FUNCTION: void* bug1021_test_1 ( void* s, int x ) ;
! Sanity test the formula: x sq s +
{ t } [
10 [ [ 100 random ] twice 2array ] replicate
[ [ first2 [ <alien> ] dip bug1021_test_1 alien-address ] map ]
[ [ first2 sq + ] map ] bi =
] unit-test
: each-to100 ( ... quot: ( ... i -- ... ) i -- ... )
dup 100 < [
2dup swap (call) 1 + each-to100
] [ 2drop ] if ; inline recursive
: run-test ( alien -- seq )
100 33 <array> swap over
[
pick swapd
bug1021_test_1
-rot swap 2 fixnum+fast
set-slot
] curry curry 0 each-to100 ;
{ } [
minor-gc 2000 [
101 <alien> run-test
! If #1021 ever comes back it will blow up here because
! alien-address wants an alien not a fixnum.
[ alien-address ] map drop
] times
] unit-test
FUNCTION: int bug1021_test_2 ( int a, char* b, void* c ) ;
FUNCTION: void* bug1021_test_3 ( c-string a ) ;
: doit ( a -- d )
33 1byte-array "bar" bug1021_test_3 bug1021_test_2 ;
{ } [
10000 [ 0 doit 33 assert= ] times
] unit-test