@@ -24,10 +24,27 @@ var tape = require( 'tape' );
24
24
var abs = require ( '@stdlib/math/base/special/abs' ) ;
25
25
var dabs = require ( '@stdlib/math/strided/special/dabs' ) ;
26
26
var sabs = require ( '@stdlib/math/strided/special/sabs' ) ;
27
- var gabs = require ( '@stdlib/math/strided/special/gabs ' ) ;
27
+ var gabs = require ( '@stdlib/math/strided/special/abs ' ) ;
28
28
var validate = require ( './../lib/validate.js' ) ;
29
29
30
30
31
+ // FUNCTIONS //
32
+
33
+ /**
34
+ * Returns a destination object.
35
+ *
36
+ * @private
37
+ * @returns {Object } destination object
38
+ */
39
+ function output ( ) {
40
+ return {
41
+ 'scalar' : [ ] ,
42
+ 'array' : [ ] ,
43
+ 'ndarray' : [ ]
44
+ } ;
45
+ }
46
+
47
+
31
48
// TESTS //
32
49
33
50
tape ( 'main export is a function' , function test ( t ) {
@@ -54,7 +71,7 @@ tape( 'the function returns an error if provided a `table` argument which is not
54
71
] ;
55
72
56
73
for ( i = 0 ; i < values . length ; i ++ ) {
57
- err = validate ( { } , values [ i ] ) ;
74
+ err = validate ( output ( ) , values [ i ] ) ;
58
75
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
59
76
}
60
77
t . end ( ) ;
@@ -82,7 +99,7 @@ tape( 'the function returns an error if provided a "scalar" field value which is
82
99
opts = {
83
100
'scalar' : values [ i ]
84
101
} ;
85
- err = validate ( { } , opts ) ;
102
+ err = validate ( output ( ) , opts ) ;
86
103
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
87
104
}
88
105
t . end ( ) ;
@@ -110,7 +127,7 @@ tape( 'the function returns an error if provided an "array" field value which is
110
127
opts = {
111
128
'array' : values [ i ]
112
129
} ;
113
- err = validate ( { } , opts ) ;
130
+ err = validate ( output ( ) , opts ) ;
114
131
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
115
132
}
116
133
t . end ( ) ;
@@ -138,7 +155,7 @@ tape( 'the function returns an error if provided an "ndarray" field value which
138
155
opts = {
139
156
'ndarray' : values [ i ]
140
157
} ;
141
- err = validate ( { } , opts ) ;
158
+ err = validate ( output ( ) , opts ) ;
142
159
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
143
160
}
144
161
t . end ( ) ;
@@ -160,7 +177,7 @@ tape( 'the function returns an error if provided a "scalar" field value having a
160
177
opts = {
161
178
'scalar' : values [ i ]
162
179
} ;
163
- err = validate ( { } , opts ) ;
180
+ err = validate ( output ( ) , opts ) ;
164
181
t . strictEqual ( err instanceof Error , true , 'returns an error when provided ' + values [ i ] ) ;
165
182
}
166
183
t . end ( ) ;
@@ -182,7 +199,7 @@ tape( 'the function returns an error if provided an "array" field value having a
182
199
opts = {
183
200
'array' : values [ i ]
184
201
} ;
185
- err = validate ( { } , opts ) ;
202
+ err = validate ( output ( ) , opts ) ;
186
203
t . strictEqual ( err instanceof Error , true , 'returns an error when provided ' + values [ i ] ) ;
187
204
}
188
205
t . end ( ) ;
@@ -204,7 +221,7 @@ tape( 'the function returns an error if provided an "ndarray" field value having
204
221
opts = {
205
222
'ndarray' : values [ i ]
206
223
} ;
207
- err = validate ( { } , opts ) ;
224
+ err = validate ( output ( ) , opts ) ;
208
225
t . strictEqual ( err instanceof Error , true , 'returns an error when provided ' + values [ i ] ) ;
209
226
}
210
227
t . end ( ) ;
@@ -228,7 +245,7 @@ tape( 'the function returns an error if provided a "scalar" field value which do
228
245
opts = {
229
246
'scalar' : values [ i ]
230
247
} ;
231
- err = validate ( { } , opts ) ;
248
+ err = validate ( output ( ) , opts ) ;
232
249
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
233
250
}
234
251
t . end ( ) ;
@@ -252,7 +269,7 @@ tape( 'the function returns an error if provided an "array" field value which do
252
269
opts = {
253
270
'array' : values [ i ]
254
271
} ;
255
- err = validate ( { } , opts ) ;
272
+ err = validate ( output ( ) , opts ) ;
256
273
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
257
274
}
258
275
t . end ( ) ;
@@ -276,19 +293,19 @@ tape( 'the function returns an error if provided an "ndarray" field value which
276
293
opts = {
277
294
'array' : values [ i ]
278
295
} ;
279
- err = validate ( { } , opts ) ;
296
+ err = validate ( output ( ) , opts ) ;
280
297
t . strictEqual ( err instanceof TypeError , true , 'returns a type error when provided ' + values [ i ] ) ;
281
298
}
282
299
t . end ( ) ;
283
300
} ) ;
284
301
285
- tape ( 'the function returns `null` if all options are valid' , function test ( t ) {
286
- var options ;
287
- var opts ;
302
+ tape ( 'the function returns `null` if provided a valid table object ' , function test ( t ) {
303
+ var table ;
304
+ var out ;
288
305
var err ;
289
306
290
- opts = { } ;
291
- options = {
307
+ out = output ( ) ;
308
+ table = {
292
309
'scalar' : [
293
310
'number' ,
294
311
abs
@@ -311,27 +328,27 @@ tape( 'the function returns `null` if all options are valid', function test( t )
311
328
]
312
329
} ;
313
330
314
- err = validate ( opts , options ) ;
331
+ err = validate ( out , table ) ;
315
332
t . strictEqual ( err , null , 'returns null' ) ;
316
- t . deepEqual ( opts , options , 'sets options ' ) ;
333
+ t . deepEqual ( out , table , 'sets fields ' ) ;
317
334
318
335
t . end ( ) ;
319
336
} ) ;
320
337
321
338
tape ( 'the function will ignore unrecognized table fields' , function test ( t ) {
322
- var options ;
323
- var opts ;
339
+ var table ;
340
+ var out ;
324
341
var err ;
325
342
326
- opts = { } ;
327
- options = {
328
- 'beep' : true ,
329
- 'boop' : 'bop'
343
+ out = output ( ) ;
344
+ table = {
345
+ 'beep' : [ ] ,
346
+ 'boop' : [ ]
330
347
} ;
331
348
332
- err = validate ( opts , options ) ;
349
+ err = validate ( out , table ) ;
333
350
t . strictEqual ( err , null , 'returns null' ) ;
334
- t . deepEqual ( opts , { } , 'ignores unrecognized options ' ) ;
351
+ t . deepEqual ( out , output ( ) , 'ignores unrecognized fields ' ) ;
335
352
336
353
t . end ( ) ;
337
354
} ) ;
0 commit comments