]> gitweb.factorcode.org Git - factor.git/blob - extra/gml/test-coremath.gml
vm: fix arm files
[factor.git] / extra / gml / test-coremath.gml
1 % Missing math words:
2 % aNormal
3
4 "Arithmetic" print
5 [17] [9 8 add] test
6 [(10,20)] [(5,14) (5,6) add] test
7 [(10,20,30)] [(5,14,23) (5,6,7) add] test
8
9 [-34] [30 64 sub] test
10 [(0,8,16)] [(5,14,23) (5,6,7) sub] test
11
12 [1170] [117 10 mul] test
13 [(15,42)] [(5,14) 3 mul] test
14 [(10,28)] [2 (5,14) mul] test
15 [(15,42,69)] [(5,14,23) 3 mul] test
16 [(10,28,46)] [2 (5,14,23) mul] test
17 [2.0] [(1,0) (2,3) mul] test
18 [6.0] [(1,0,1) (2,3,4) mul] test
19
20 % Stupid bug with vec3 dot product
21 [20.0] [(1,0,1) 1 add (2,4,6) mul] test
22
23 [0.125] [2 16 div] test
24 [(1,4,10)] [(2,8,20) 2 div] test
25
26 [3] [7 4 mod] test
27
28 [-1.0] [1.0 neg] test
29
30 [(-1,-2)] [(1,2) neg] test
31 [(-1,-2,-3)] [(1,2,3) neg] test
32
33 "Comparisons" print
34 [1] [1 1 eq] test
35 [0] [1 2 eq] test
36 [0] [1 1 ne] test
37 [1] [1 2 ne] test
38 [1] [1 0 ge] test
39 [1] [1 1 ge] test
40 [0] [1 2 ge] test
41 [1] [1 0 gt] test
42 [0] [1 1 gt] test
43 [0] [1 2 gt] test
44 [0] [1 0 le] test
45 [1] [1 1 le] test
46 [1] [1 2 le] test
47 [0] [1 0 lt] test
48 [0] [1 1 lt] test
49 [1] [1 2 lt] test
50
51 [-1.0] [-2.0 (-1.0,10.0) clamp] test
52 [0.5] [0.5 (-1.0,10.0) clamp] test
53 [10.0] [22.0 (-1.0,10.0) clamp] test
54
55 "Logical operators" print
56 [0] [0 0 and] test
57 [0] [0 1 and] test
58 [0] [0.0 0 and] test
59 [0] [0.0 0.0 and] test
60 [1] [1.0 1 and] test
61 [1] [1.0 "hi" and] test
62
63 [0] [0 0 or] test
64 [1] [0 1 or] test
65 [0] [0.0 0 or] test
66 [0] [0.0 0.0 or] test
67 [1] [1.0 1 or] test
68 [1] [1.0 "hi" or] test
69
70 [1] [0 not] test
71 [1] [0.0 not] test
72 [0] [1 not] test
73 [0] ["Hi" not] test
74
75 "Functions" print
76 [126.42] [-126.42 abs] test
77 [5.0] [(3,4) abs] test
78 [129.0] [128.15 ceiling] test
79 [128.0] [128.95 floor] test
80 [-13.0] [-12.35 floor] test
81 [12.0] [12.34 trunc] test
82 [12] [12 trunc] test
83 [-12.0] [-12.35 trunc] test
84 [12.0] [12.34 round] test
85 [13.0] [12.64 round] test
86 [-12.0] [-12.35 round] test
87 [-13.0] [-12.65 round] test
88 [2.0] [4 sqrt] test
89
90 [0.25] [4 inv] test
91 [3.0] [1000 log] test
92 [1000.0] [10 3 pow] test
93
94 [180.0] [-1 acos] test
95 [0.0] [1 acos] test
96 [-90.0] [-1 asin] test
97 [90.0] [1 asin] test
98 [-45.0] [-1 atan] test
99 [45.0] [1 atan] test
100 [45.0] [1 1 atan2] test
101 [135.0] [1 -1 atan2] test
102 [-45.0] [-1 1 atan2] test
103
104 "Vector operations" print
105 [5.0] [(5.0,1.3) getX] test
106 [1.3] [(5.0,1.3) getY] test
107 [5.0] [(5.0,1.3,2.7) getX] test
108 [1.3] [(5.0,1.3,2.7) getY] test
109 [2.7] [(5.0,1.3,2.7) getZ] test
110
111 [(1.7,1.3)] [(5.0,1.3) 1.7 putX] test
112 [(5.0,1.7)] [(5.0,1.3) 1.7 putY] test
113 [(1.7,1.3,2.7)] [(5.0,1.3,2.7) 1.7 putX] test
114 [(5.0,1.7,2.7)] [(5.0,1.3,2.7) 1.7 putY] test
115 [(5.0,1.3,1.7)] [(5.0,1.3,2.7) 1.7 putZ] test
116
117 [(5.0,1.3)] [5.0 1.3 vector2] test
118 [(5.0,1.3,2.7)] [5.0 1.3 2.7 vector3] test
119
120 [(3.5,4.1,0.0)] [(1.0,0.0,0.0) (0.0,1.0,0.0) (3.5,4.1) planemul] test
121
122 [(0.0,0.0,1.0)] [(1.0,0.0,0.0) (0.0,1.0,0.0) cross] test
123 [(0.0,-1.0,0.0)] [(1.0,0.0,0.0) (0.0,0.0,1.0) cross] test
124
125 [(-0.0,1)] [(1,0) aNormal] test
126 [(-0.0,-1)] [(-1,0) aNormal] test
127 [(-1,0)] [(0,1) aNormal] test
128 [(1,0)] [(0,-1) aNormal] test
129 % [(0.0,1,0)] [(1,0,0) aNormal] test
130 % [(-0.0,-1,0)] [(-1,0,0) aNormal] test
131 % [(-1,0,0)] [(0,1,0) aNormal] test
132 % [(1,0,0)] [(0,-1,0) aNormal] test
133 % [(-1,0,0)] [(0,0,1) aNormal] test
134 % [(1,0,0)] [(0,0,-1) aNormal] test
135
136 [-2.0] [(1,2) (3,4) determinant] test
137 [0.0] [(1,2,3) (4,5,6) (7,8,9) determinant] test
138 [6.0] [(1,2,3) (4,5,6) (7,8,7) determinant] test
139
140 "Fibonacci" print
141
142 dict begin
143
144     /fib {
145      dup 1 le {pop 1} {dup 1 sub fib exch 2 sub fib add} ifelse
146     } def
147
148     [121393] [25 fib] test
149
150     /fibreg {
151      dup 1 le
152      {pop 1}
153      {
154      usereg !n
155      ;n 1 sub fib !x
156      ;n 2 sub fib !y
157      ;x ;y add
158      } ifelse
159     } def
160
161     [121393] [25 fibreg] test
162
163 end
164
165 "Make sure nothing is left on the stack after the test" print
166 count [exch] [0] test