|
21 | 21 | // MODULES //
|
22 | 22 |
|
23 | 23 | var tape = require( 'tape' );
|
24 |
| -var abs = require( '@stdlib/math-base-special-abs' ); |
25 |
| -var zeros4d = require( '@stdlib/array-base-zeros4d' ); |
26 |
| -var unary4d = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
27 | 25 |
|
28 | 26 |
|
29 | 27 | // TESTS //
|
30 | 28 |
|
31 |
| -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
32 | 30 | t.ok( true, __filename );
|
33 |
| - t.strictEqual( typeof unary4d, 'function', 'main export is a function' ); |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
34 | 32 | t.end();
|
35 | 33 | });
|
36 |
| - |
37 |
| -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { |
38 |
| - var expected; |
39 |
| - var shape; |
40 |
| - var x; |
41 |
| - var y; |
42 |
| - |
43 |
| - shape = [ 2, 2, 2, 2 ]; |
44 |
| - x = [ |
45 |
| - [ |
46 |
| - [ |
47 |
| - [ -1.0, -2.0 ], |
48 |
| - [ -3.0, -4.0 ] |
49 |
| - ], |
50 |
| - [ |
51 |
| - [ -1.0, -2.0 ], |
52 |
| - [ -3.0, -4.0 ] |
53 |
| - ] |
54 |
| - ], |
55 |
| - [ |
56 |
| - [ |
57 |
| - [ -1.0, -2.0 ], |
58 |
| - [ -3.0, -4.0 ] |
59 |
| - ], |
60 |
| - [ |
61 |
| - [ -1.0, -2.0 ], |
62 |
| - [ -3.0, -4.0 ] |
63 |
| - ] |
64 |
| - ] |
65 |
| - ]; |
66 |
| - |
67 |
| - expected = [ |
68 |
| - [ |
69 |
| - [ |
70 |
| - [ 1.0, 2.0 ], |
71 |
| - [ 3.0, 4.0 ] |
72 |
| - ], |
73 |
| - [ |
74 |
| - [ 1.0, 2.0 ], |
75 |
| - [ 3.0, 4.0 ] |
76 |
| - ] |
77 |
| - ], |
78 |
| - [ |
79 |
| - [ |
80 |
| - [ 1.0, 2.0 ], |
81 |
| - [ 3.0, 4.0 ] |
82 |
| - ], |
83 |
| - [ |
84 |
| - [ 1.0, 2.0 ], |
85 |
| - [ 3.0, 4.0 ] |
86 |
| - ] |
87 |
| - ] |
88 |
| - ]; |
89 |
| - |
90 |
| - y = zeros4d( shape ); |
91 |
| - unary4d( [ x, y ], shape, abs ); |
92 |
| - |
93 |
| - t.deepEqual( y, expected, 'returns expected value' ); |
94 |
| - t.end(); |
95 |
| -}); |
96 |
| - |
97 |
| -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { |
98 |
| - var expected; |
99 |
| - var shape; |
100 |
| - var x; |
101 |
| - var y; |
102 |
| - |
103 |
| - shape = [ 2, 2, 2, 2 ]; |
104 |
| - x = [ |
105 |
| - [ |
106 |
| - [ |
107 |
| - [ -1.0, -2.0 ], |
108 |
| - [ -3.0, -4.0 ] |
109 |
| - ], |
110 |
| - [ |
111 |
| - [ -1.0, -2.0 ], |
112 |
| - [ -3.0, -4.0 ] |
113 |
| - ] |
114 |
| - ], |
115 |
| - [ |
116 |
| - [ |
117 |
| - [ -1.0, -2.0 ], |
118 |
| - [ -3.0, -4.0 ] |
119 |
| - ], |
120 |
| - [ |
121 |
| - [ -1.0, -2.0 ], |
122 |
| - [ -3.0, -4.0 ] |
123 |
| - ] |
124 |
| - ] |
125 |
| - ]; |
126 |
| - |
127 |
| - expected = zeros4d( shape ); |
128 |
| - |
129 |
| - y = zeros4d( shape ); |
130 |
| - unary4d( [ x, y ], [ 0, 2, 2, 2 ], clbk ); |
131 |
| - |
132 |
| - t.deepEqual( y, expected, 'returns expected value' ); |
133 |
| - t.end(); |
134 |
| - |
135 |
| - function clbk() { |
136 |
| - t.ok( false, 'should not invoke callback' ); |
137 |
| - } |
138 |
| -}); |
139 |
| - |
140 |
| -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { |
141 |
| - var expected; |
142 |
| - var shape; |
143 |
| - var x; |
144 |
| - var y; |
145 |
| - |
146 |
| - shape = [ 2, 2, 2, 2 ]; |
147 |
| - x = [ |
148 |
| - [ |
149 |
| - [ |
150 |
| - [ -1.0, -2.0 ], |
151 |
| - [ -3.0, -4.0 ] |
152 |
| - ], |
153 |
| - [ |
154 |
| - [ -1.0, -2.0 ], |
155 |
| - [ -3.0, -4.0 ] |
156 |
| - ] |
157 |
| - ], |
158 |
| - [ |
159 |
| - [ |
160 |
| - [ -1.0, -2.0 ], |
161 |
| - [ -3.0, -4.0 ] |
162 |
| - ], |
163 |
| - [ |
164 |
| - [ -1.0, -2.0 ], |
165 |
| - [ -3.0, -4.0 ] |
166 |
| - ] |
167 |
| - ] |
168 |
| - ]; |
169 |
| - |
170 |
| - expected = zeros4d( shape ); |
171 |
| - |
172 |
| - y = zeros4d( shape ); |
173 |
| - unary4d( [ x, y ], [ 2, 0, 2, 2 ], clbk ); |
174 |
| - |
175 |
| - t.deepEqual( y, expected, 'returns expected value' ); |
176 |
| - t.end(); |
177 |
| - |
178 |
| - function clbk() { |
179 |
| - t.ok( false, 'should not invoke callback' ); |
180 |
| - } |
181 |
| -}); |
182 |
| - |
183 |
| -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { |
184 |
| - var expected; |
185 |
| - var shape; |
186 |
| - var x; |
187 |
| - var y; |
188 |
| - |
189 |
| - shape = [ 2, 2, 2, 2 ]; |
190 |
| - x = [ |
191 |
| - [ |
192 |
| - [ |
193 |
| - [ -1.0, -2.0 ], |
194 |
| - [ -3.0, -4.0 ] |
195 |
| - ], |
196 |
| - [ |
197 |
| - [ -1.0, -2.0 ], |
198 |
| - [ -3.0, -4.0 ] |
199 |
| - ] |
200 |
| - ], |
201 |
| - [ |
202 |
| - [ |
203 |
| - [ -1.0, -2.0 ], |
204 |
| - [ -3.0, -4.0 ] |
205 |
| - ], |
206 |
| - [ |
207 |
| - [ -1.0, -2.0 ], |
208 |
| - [ -3.0, -4.0 ] |
209 |
| - ] |
210 |
| - ] |
211 |
| - ]; |
212 |
| - |
213 |
| - expected = zeros4d( shape ); |
214 |
| - |
215 |
| - y = zeros4d( shape ); |
216 |
| - unary4d( [ x, y ], [ 2, 2, 0, 2 ], clbk ); |
217 |
| - |
218 |
| - t.deepEqual( y, expected, 'returns expected value' ); |
219 |
| - t.end(); |
220 |
| - |
221 |
| - function clbk() { |
222 |
| - t.ok( false, 'should not invoke callback' ); |
223 |
| - } |
224 |
| -}); |
225 |
| - |
226 |
| -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { |
227 |
| - var expected; |
228 |
| - var shape; |
229 |
| - var x; |
230 |
| - var y; |
231 |
| - |
232 |
| - shape = [ 2, 2, 2, 2 ]; |
233 |
| - x = [ |
234 |
| - [ |
235 |
| - [ |
236 |
| - [ -1.0, -2.0 ], |
237 |
| - [ -3.0, -4.0 ] |
238 |
| - ], |
239 |
| - [ |
240 |
| - [ -1.0, -2.0 ], |
241 |
| - [ -3.0, -4.0 ] |
242 |
| - ] |
243 |
| - ], |
244 |
| - [ |
245 |
| - [ |
246 |
| - [ -1.0, -2.0 ], |
247 |
| - [ -3.0, -4.0 ] |
248 |
| - ], |
249 |
| - [ |
250 |
| - [ -1.0, -2.0 ], |
251 |
| - [ -3.0, -4.0 ] |
252 |
| - ] |
253 |
| - ] |
254 |
| - ]; |
255 |
| - |
256 |
| - expected = zeros4d( shape ); |
257 |
| - |
258 |
| - y = zeros4d( shape ); |
259 |
| - unary4d( [ x, y ], [ 2, 2, 2, 0 ], clbk ); |
260 |
| - |
261 |
| - t.deepEqual( y, expected, 'returns expected value' ); |
262 |
| - t.end(); |
263 |
| - |
264 |
| - function clbk() { |
265 |
| - t.ok( false, 'should not invoke callback' ); |
266 |
| - } |
267 |
| -}); |
0 commit comments