2 USING: accessors alien alien.accessors alien.syntax byte-arrays arrays
3 kernel kernel.private namespaces tools.test sequences libc math
4 system prettyprint layouts ;
6 [ t ] [ -1 <alien> alien-address 0 > ] unit-test
8 [ t ] [ 0 <alien> 0 <alien> = ] unit-test
9 [ f ] [ 0 <alien> 1024 <alien> = ] unit-test
10 [ f ] [ "hello" 1024 <alien> = ] unit-test
11 [ f ] [ 0 <alien> ] unit-test
12 [ f ] [ 0 f <displaced-alien> ] unit-test
14 ! Testing the various bignum accessor
15 10 <byte-array> "dump" set
17 [ "dump" get alien-address ] must-fail
20 123 "dump" get 0 set-alien-signed-1
21 "dump" get 0 alien-signed-1
25 12345 "dump" get 0 set-alien-signed-2
26 "dump" get 0 alien-signed-2
30 12345678 "dump" get 0 set-alien-signed-4
31 "dump" get 0 alien-signed-4
34 [ 12345678901234567 ] [
35 12345678901234567 "dump" get 0 set-alien-signed-8
36 "dump" get 0 alien-signed-8
40 -1 "dump" get 0 set-alien-signed-8
41 "dump" get 0 alien-signed-8
45 [ HEX: 123412341234 ] [
47 HEX: 123412341234 over 0 set-alien-signed-8
51 [ HEX: 123412341234 ] [
53 HEX: 123412341234 over 0 set-alien-signed-cell
58 [ "ALIEN: 1234" ] [ 1234 <alien> unparse ] unit-test
60 [ ] [ 0 B{ 1 2 3 } <displaced-alien> drop ] unit-test
62 [ 0 B{ 1 2 3 } <displaced-alien> alien-address ] must-fail
64 [ 1 1 <displaced-alien> ] must-fail
66 [ f ] [ 0 B{ 1 2 3 } <displaced-alien> pinned-c-ptr? ] unit-test
68 [ f ] [ 0 B{ 1 2 3 } <displaced-alien> 1 swap <displaced-alien> pinned-c-ptr? ] unit-test
70 [ t ] [ 0 B{ 1 2 3 } <displaced-alien> 1 swap <displaced-alien> underlying>> byte-array? ] unit-test
72 [ "( displaced alien )" ] [ 0 B{ 1 2 3 } <displaced-alien> unparse ] unit-test
74 [ f ] [ DLL" fadfasdfsada" dll-valid? ] unit-test
76 [ f ] [ "does not exist" DLL" fadsfasfdsaf" dlsym ] unit-test