Skip to content

Commit de52a29

Browse files
committed
test: fix descriptions and add error condition tests
1 parent 962c155 commit de52a29

2 files changed

Lines changed: 58 additions & 6 deletions

File tree

lib/node_modules/@stdlib/array/to-fancy/test/test.get.boolean_array.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ tape( 'the function returns an array-like object supporting boolean array indexi
9999
t.end();
100100
});
101101

102-
tape( 'the function returns an array-like object boolean array indexing (typed)', opts, function test( t ) {
102+
tape( 'the function returns an array-like object supporting boolean array indexing and returning arrays (typed)', opts, function test( t ) {
103103
var expected;
104104
var actual;
105105
var idx;
@@ -157,7 +157,7 @@ tape( 'the function returns an array-like object boolean array indexing (typed)'
157157
t.end();
158158
});
159159

160-
tape( 'the function returns an array-like object boolean array indexing which can themselves support boolean arrays (generic)', opts, function test( t ) {
160+
tape( 'the function returns an array-like object supporting boolean array indexing and returning arrays which can themselves support boolean arrays (generic)', opts, function test( t ) {
161161
var expected;
162162
var actual;
163163
var idx;
@@ -204,7 +204,7 @@ tape( 'the function returns an array-like object boolean array indexing which ca
204204
t.end();
205205
});
206206

207-
tape( 'the function returns an array-like object boolean array indexing which can themselves support boolean arrays (typed)', opts, function test( t ) {
207+
tape( 'the function returns an array-like object supporting boolean array indexing and returning arrays which can themselves support boolean arrays (typed)', opts, function test( t ) {
208208
var expected;
209209
var actual;
210210
var idx;
@@ -250,3 +250,55 @@ tape( 'the function returns an array-like object boolean array indexing which ca
250250

251251
t.end();
252252
});
253+
254+
tape( 'the function returns an array-like object which throws an error if provided a boolean array index having an incompatible number of elements (generic)', opts, function test( t ) {
255+
var values;
256+
var x;
257+
var y;
258+
var i;
259+
260+
x = [ 1, 2, 3, 4 ];
261+
y = array2fancy( x );
262+
263+
values = [
264+
array2fancy.idx( [ true, false ] ),
265+
array2fancy.idx( [ true, true, true ] ),
266+
array2fancy.idx( [ true, false, true, false, true ] )
267+
];
268+
for ( i = 0; i < values.length; i++ ) {
269+
t.throws( badValue( values[ i ] ), Error, 'throws an error' );
270+
}
271+
t.end();
272+
273+
function badValue( value ) {
274+
return function badValue() {
275+
var v = y[ value ]; // eslint-disable-line no-unused-vars
276+
};
277+
}
278+
});
279+
280+
tape( 'the function returns an array-like object which throws an error if provided a boolean array index having an incompatible number of elements (typed)', opts, function test( t ) {
281+
var values;
282+
var x;
283+
var y;
284+
var i;
285+
286+
x = new Int32Array( [ 1, 2, 3, 4 ] );
287+
y = array2fancy( x );
288+
289+
values = [
290+
array2fancy.idx( [ true, false ] ),
291+
array2fancy.idx( [ true, true, true ] ),
292+
array2fancy.idx( [ true, false, true, false, true ] )
293+
];
294+
for ( i = 0; i < values.length; i++ ) {
295+
t.throws( badValue( values[ i ] ), Error, 'throws an error' );
296+
}
297+
t.end();
298+
299+
function badValue( value ) {
300+
return function badValue() {
301+
var v = y[ value ]; // eslint-disable-line no-unused-vars
302+
};
303+
}
304+
});

lib/node_modules/@stdlib/array/to-fancy/test/test.get.integer_array.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ tape( 'the function returns an array-like object supporting integer array indexi
126126
t.end();
127127
});
128128

129-
tape( 'the function returns an array-like object integer array indexing (typed)', opts, function test( t ) {
129+
tape( 'the function returns an array-like object supporting integer array indexing (typed)', opts, function test( t ) {
130130
var expected;
131131
var actual;
132132
var idx;
@@ -375,7 +375,7 @@ tape( 'when `strict` is `true`, the function returns an array-like object which
375375
}
376376
});
377377

378-
tape( 'the function returns an array-like object integer array indexing which can themselves support integer arrays (generic)', opts, function test( t ) {
378+
tape( 'the function returns an array-like object supporting integer array indexing and returning arrays which themselves support integer arrays (generic)', opts, function test( t ) {
379379
var expected;
380380
var actual;
381381
var idx;
@@ -422,7 +422,7 @@ tape( 'the function returns an array-like object integer array indexing which ca
422422
t.end();
423423
});
424424

425-
tape( 'the function returns an array-like object integer array indexing which can themselves support integer arrays (typed)', opts, function test( t ) {
425+
tape( 'the function returns an array-like object supporting integer array indexing and returning arrays which themselves support integer arrays (typed)', opts, function test( t ) {
426426
var expected;
427427
var actual;
428428
var idx;

0 commit comments

Comments
 (0)