]> gitweb.factorcode.org Git - factor.git/blob - extra/classes/struct/vectored/vectored-tests.factor
163de7d25fdad080c67f51b43d7263000384903e
[factor.git] / extra / classes / struct / vectored / vectored-tests.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: accessors alien.c-types classes.struct classes.struct.vectored
3 kernel sequences specialized-arrays tools.test vocabs compiler.units ;
4 FROM: specialized-arrays.private => specialized-array-vocab ;
5 SPECIALIZED-ARRAYS: int ushort float ;
6 IN: classes.struct.vectored.tests
7
8 STRUCT: foo
9     { x int }
10     { y float }
11     { z ushort }
12     { w ushort } ;
13
14 SPECIALIZED-ARRAY: foo
15 VECTORED-STRUCT: foo
16
17 {
18     T{ vectored-foo
19         { x int-array{    0   1   0   0   } }
20         { y float-array{  0.0 2.0 0.0 0.0 } }
21         { z ushort-array{ 0   3   0   0   } }
22         { w ushort-array{ 0   4   0   0   } }
23     }
24 } [ S{ foo f 1 2.0 3 4 } 4 <vectored-foo> [ set-second ] keep ] unit-test
25
26 {
27     T{ vectored-foo
28         { x int-array{     0    1    2    3   } }
29         { y float-array{   0.0  0.5  1.0  1.5 } }
30         { z ushort-array{ 10   20   30   40   } }
31         { w ushort-array{ 15   25   35   45   } }
32     }
33 } [
34     foo-array{
35         S{ foo { x 0 } { y 0.0 } { z 10 } { w 15 } }
36         S{ foo { x 1 } { y 0.5 } { z 20 } { w 25 } }
37         S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } }
38         S{ foo { x 3 } { y 1.5 } { z 40 } { w 45 } }
39     } struct-transpose
40 ] unit-test
41
42 {
43     foo-array{
44         S{ foo { x 0 } { y 0.0 } { z 10 } { w 15 } }
45         S{ foo { x 1 } { y 0.5 } { z 20 } { w 25 } }
46         S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } }
47         S{ foo { x 3 } { y 1.5 } { z 40 } { w 45 } }
48     }
49 } [
50     T{ vectored-foo
51         { x int-array{     0    1    2    3   } }
52         { y float-array{   0.0  0.5  1.0  1.5 } }
53         { z ushort-array{ 10   20   30   40   } }
54         { w ushort-array{ 15   25   35   45   } }
55     } struct-transpose
56 ] unit-test
57
58 { 30 } [
59     T{ vectored-foo
60         { x int-array{     0    1    2    3   } }
61         { y float-array{   0.0  0.5  1.0  1.5 } }
62         { z ushort-array{ 10   20   30   40   } }
63         { w ushort-array{ 15   25   35   45   } }
64     } third z>>
65 ] unit-test
66
67 { S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } } } [
68     T{ vectored-foo
69         { x int-array{     0    1    2    3   } }
70         { y float-array{   0.0  0.5  1.0  1.5 } }
71         { z ushort-array{ 10   20   30   40   } }
72         { w ushort-array{ 15   25   35   45   } }
73     } third vectored-element>
74 ] unit-test
75
76 { } [
77     [
78         foo specialized-array-vocab forget-vocab
79     ] with-compilation-unit
80 ] unit-test