1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types classes.struct classes.struct.vectored
4 kernel sequences specialized-arrays tools.test vocabs compiler.units ;
5 FROM: specialized-arrays.private => specialized-array-vocab ;
6 SPECIALIZED-ARRAYS: int ushort float ;
7 IN: classes.struct.vectored.tests
15 SPECIALIZED-ARRAY: foo
20 { x int-array{ 0 1 0 0 } }
21 { y float-array{ 0.0 2.0 0.0 0.0 } }
22 { z ushort-array{ 0 3 0 0 } }
23 { w ushort-array{ 0 4 0 0 } }
25 } [ S{ foo f 1 2.0 3 4 } 4 <vectored-foo> [ set-second ] keep ] unit-test
29 { x int-array{ 0 1 2 3 } }
30 { y float-array{ 0.0 0.5 1.0 1.5 } }
31 { z ushort-array{ 10 20 30 40 } }
32 { w ushort-array{ 15 25 35 45 } }
36 S{ foo { x 0 } { y 0.0 } { z 10 } { w 15 } }
37 S{ foo { x 1 } { y 0.5 } { z 20 } { w 25 } }
38 S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } }
39 S{ foo { x 3 } { y 1.5 } { z 40 } { w 45 } }
45 S{ foo { x 0 } { y 0.0 } { z 10 } { w 15 } }
46 S{ foo { x 1 } { y 0.5 } { z 20 } { w 25 } }
47 S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } }
48 S{ foo { x 3 } { y 1.5 } { z 40 } { w 45 } }
52 { x int-array{ 0 1 2 3 } }
53 { y float-array{ 0.0 0.5 1.0 1.5 } }
54 { z ushort-array{ 10 20 30 40 } }
55 { w ushort-array{ 15 25 35 45 } }
61 { x int-array{ 0 1 2 3 } }
62 { y float-array{ 0.0 0.5 1.0 1.5 } }
63 { z ushort-array{ 10 20 30 40 } }
64 { w ushort-array{ 15 25 35 45 } }
68 { S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } } } [
70 { x int-array{ 0 1 2 3 } }
71 { y float-array{ 0.0 0.5 1.0 1.5 } }
72 { z ushort-array{ 10 20 30 40 } }
73 { w ushort-array{ 15 25 35 45 } }
74 } third vectored-element>
79 foo specialized-array-vocab forget-vocab
80 ] with-compilation-unit