use struct class in struct-arrays test
parent
24c2eaae01
commit
469e4b526f
|
@ -1,40 +1,40 @@
|
|||
IN: struct-arrays.tests
|
||||
USING: struct-arrays tools.test kernel math sequences
|
||||
USING: classes.struct struct-arrays tools.test kernel math sequences
|
||||
alien.syntax alien.c-types destructors libc accessors sequences.private ;
|
||||
|
||||
C-STRUCT: test-struct
|
||||
{ "int" "x" }
|
||||
{ "int" "y" } ;
|
||||
STRUCT: test-struct-array
|
||||
{ x int }
|
||||
{ y int } ;
|
||||
|
||||
: make-point ( x y -- struct )
|
||||
"test-struct" <c-object>
|
||||
[ set-test-struct-y ] keep
|
||||
[ set-test-struct-x ] keep ;
|
||||
test-struct-array <struct-boa> ;
|
||||
|
||||
[ 5/4 ] [
|
||||
2 "test-struct" <struct-array>
|
||||
2 test-struct-array <struct-array>
|
||||
1 2 make-point over set-first
|
||||
3 4 make-point over set-second
|
||||
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
|
||||
0 [ [ x>> ] [ y>> ] bi / + ] reduce
|
||||
] unit-test
|
||||
|
||||
[ 5/4 ] [
|
||||
[
|
||||
2 "test-struct" malloc-struct-array
|
||||
2 test-struct-array malloc-struct-array
|
||||
dup &free drop
|
||||
1 2 make-point over set-first
|
||||
3 4 make-point over set-second
|
||||
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
|
||||
0 [ [ x>> ] [ y>> ] bi / + ] reduce
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
[ ] [ ALIEN: 123 10 "test-struct" <direct-struct-array> drop ] unit-test
|
||||
[ ] [ ALIEN: 123 10 test-struct-array <direct-struct-array> drop ] unit-test
|
||||
|
||||
[ ] [
|
||||
[
|
||||
10 "test-struct" malloc-struct-array
|
||||
10 test-struct-array malloc-struct-array
|
||||
&free drop
|
||||
] with-destructors
|
||||
] unit-test
|
||||
|
||||
[ 15 ] [ 15 10 "test-struct" <struct-array> resize length ] unit-test
|
||||
[ 15 ] [ 15 10 test-struct-array <struct-array> resize length ] unit-test
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue