]> gitweb.factorcode.org Git - factor.git/blob - extra/classes/struct/vectored/vectored-tests.factor
Update some copyright headers to follow the current convention
[factor.git] / extra / classes / struct / vectored / vectored-tests.factor
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
8
9 STRUCT: foo
10     { x int }
11     { y float }
12     { z ushort }
13     { w ushort } ;
14
15 SPECIALIZED-ARRAY: foo
16 VECTORED-STRUCT: foo
17
18 {
19     T{ vectored-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   } }
24     }
25 } [ S{ foo f 1 2.0 3 4 } 4 <vectored-foo> [ set-second ] keep ] unit-test
26
27 {
28     T{ vectored-foo
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   } }
33     }
34 } [
35     foo-array{
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 } }
40     } struct-transpose
41 ] unit-test
42
43 {
44     foo-array{
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 } }
49     }
50 } [
51     T{ vectored-foo
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   } }
56     } struct-transpose
57 ] unit-test
58
59 { 30 } [
60     T{ vectored-foo
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   } }
65     } third z>>
66 ] unit-test
67
68 { S{ foo { x 2 } { y 1.0 } { z 30 } { w 35 } } } [
69     T{ vectored-foo
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>
75 ] unit-test
76
77 { } [
78     [
79         foo specialized-array-vocab forget-vocab
80     ] with-compilation-unit
81 ] unit-test