Skip to content

Commit b62117f

Browse files
committed
test: add missing test cases
1 parent 6c55278 commit b62117f

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

lib/node_modules/@stdlib/ndarray/flatten-by/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Flatten an ndarray according to a callback function.
2323
*
2424
* @module @stdlib/ndarray/flatten-by
25-
*s
25+
*
2626
* @example
2727
* var array = require( '@stdlib/ndarray/array' );
2828
* var ndarray2array = require( '@stdlib/ndarray/to-array' );

lib/node_modules/@stdlib/ndarray/flatten-by/test/test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,69 @@ tape( 'the function throws an error if provided an options argument which is not
139139
}
140140
});
141141

142+
tape( 'the function throws an error if provided an invalid `depth` option', function test( t ) {
143+
var values;
144+
var opts;
145+
var i;
146+
147+
values = [
148+
'5',
149+
-5,
150+
NaN,
151+
true,
152+
false,
153+
null,
154+
void 0,
155+
[],
156+
{},
157+
function noop() {}
158+
];
159+
for ( i = 0; i < values.length; i++ ) {
160+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
161+
}
162+
t.end();
163+
164+
function badValue( value ) {
165+
return function badValue() {
166+
opts = {
167+
'depth': value
168+
};
169+
flattenBy( zeros( [ 2 ] ), opts, clbk );
170+
};
171+
}
172+
});
173+
174+
tape( 'the function throws an error if provided an invalid `order` option', function test( t ) {
175+
var values;
176+
var opts;
177+
var i;
178+
179+
values = [
180+
'5',
181+
NaN,
182+
true,
183+
false,
184+
null,
185+
void 0,
186+
[],
187+
{},
188+
function noop() {}
189+
];
190+
for ( i = 0; i < values.length; i++ ) {
191+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
192+
}
193+
t.end();
194+
195+
function badValue( value ) {
196+
return function badValue() {
197+
opts = {
198+
'order': value
199+
};
200+
flattenBy( zeros( [ 2 ] ), opts, clbk );
201+
};
202+
}
203+
});
204+
142205
tape( 'by default, the function flattens all dimensions of a provided input ndarray in lexicographic order (row-major, contiguous)', function test( t ) {
143206
var expected;
144207
var xbuf;

0 commit comments

Comments
 (0)