Skip to content

Commit 575a26e

Browse files
committed
Fix require path and update tests
1 parent 63fda2e commit 575a26e

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

lib/node_modules/@stdlib/math/tools/unary/test/test.validate.js

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,27 @@ var tape = require( 'tape' );
2424
var abs = require( '@stdlib/math/base/special/abs' );
2525
var dabs = require( '@stdlib/math/strided/special/dabs' );
2626
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' );
2828
var validate = require( './../lib/validate.js' );
2929

3030

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+
3148
// TESTS //
3249

3350
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
5471
];
5572

5673
for ( i = 0; i < values.length; i++ ) {
57-
err = validate( {}, values[ i ] );
74+
err = validate( output(), values[ i ] );
5875
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
5976
}
6077
t.end();
@@ -82,7 +99,7 @@ tape( 'the function returns an error if provided a "scalar" field value which is
8299
opts = {
83100
'scalar': values[ i ]
84101
};
85-
err = validate( {}, opts );
102+
err = validate( output(), opts );
86103
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
87104
}
88105
t.end();
@@ -110,7 +127,7 @@ tape( 'the function returns an error if provided an "array" field value which is
110127
opts = {
111128
'array': values[ i ]
112129
};
113-
err = validate( {}, opts );
130+
err = validate( output(), opts );
114131
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
115132
}
116133
t.end();
@@ -138,7 +155,7 @@ tape( 'the function returns an error if provided an "ndarray" field value which
138155
opts = {
139156
'ndarray': values[ i ]
140157
};
141-
err = validate( {}, opts );
158+
err = validate( output(), opts );
142159
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
143160
}
144161
t.end();
@@ -160,7 +177,7 @@ tape( 'the function returns an error if provided a "scalar" field value having a
160177
opts = {
161178
'scalar': values[ i ]
162179
};
163-
err = validate( {}, opts );
180+
err = validate( output(), opts );
164181
t.strictEqual( err instanceof Error, true, 'returns an error when provided '+values[i] );
165182
}
166183
t.end();
@@ -182,7 +199,7 @@ tape( 'the function returns an error if provided an "array" field value having a
182199
opts = {
183200
'array': values[ i ]
184201
};
185-
err = validate( {}, opts );
202+
err = validate( output(), opts );
186203
t.strictEqual( err instanceof Error, true, 'returns an error when provided '+values[i] );
187204
}
188205
t.end();
@@ -204,7 +221,7 @@ tape( 'the function returns an error if provided an "ndarray" field value having
204221
opts = {
205222
'ndarray': values[ i ]
206223
};
207-
err = validate( {}, opts );
224+
err = validate( output(), opts );
208225
t.strictEqual( err instanceof Error, true, 'returns an error when provided '+values[i] );
209226
}
210227
t.end();
@@ -228,7 +245,7 @@ tape( 'the function returns an error if provided a "scalar" field value which do
228245
opts = {
229246
'scalar': values[ i ]
230247
};
231-
err = validate( {}, opts );
248+
err = validate( output(), opts );
232249
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
233250
}
234251
t.end();
@@ -252,7 +269,7 @@ tape( 'the function returns an error if provided an "array" field value which do
252269
opts = {
253270
'array': values[ i ]
254271
};
255-
err = validate( {}, opts );
272+
err = validate( output(), opts );
256273
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
257274
}
258275
t.end();
@@ -276,19 +293,19 @@ tape( 'the function returns an error if provided an "ndarray" field value which
276293
opts = {
277294
'array': values[ i ]
278295
};
279-
err = validate( {}, opts );
296+
err = validate( output(), opts );
280297
t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
281298
}
282299
t.end();
283300
});
284301

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;
288305
var err;
289306

290-
opts = {};
291-
options = {
307+
out = output();
308+
table = {
292309
'scalar': [
293310
'number',
294311
abs
@@ -311,27 +328,27 @@ tape( 'the function returns `null` if all options are valid', function test( t )
311328
]
312329
};
313330

314-
err = validate( opts, options );
331+
err = validate( out, table );
315332
t.strictEqual( err, null, 'returns null' );
316-
t.deepEqual( opts, options, 'sets options' );
333+
t.deepEqual( out, table, 'sets fields' );
317334

318335
t.end();
319336
});
320337

321338
tape( 'the function will ignore unrecognized table fields', function test( t ) {
322-
var options;
323-
var opts;
339+
var table;
340+
var out;
324341
var err;
325342

326-
opts = {};
327-
options = {
328-
'beep': true,
329-
'boop': 'bop'
343+
out = output();
344+
table = {
345+
'beep': [],
346+
'boop': []
330347
};
331348

332-
err = validate( opts, options );
349+
err = validate( out, table );
333350
t.strictEqual( err, null, 'returns null' );
334-
t.deepEqual( opts, {}, 'ignores unrecognized options' );
351+
t.deepEqual( out, output(), 'ignores unrecognized fields' );
335352

336353
t.end();
337354
});

0 commit comments

Comments
 (0)