You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -364,6 +364,165 @@ tape( 'the function throws an error if provided an options argument which is not
364
364
}
365
365
});
366
366
367
+
tape('the function throws an error if provided an options argument with an invalid `dims` property',functiontest(t){
368
+
varvalues;
369
+
varx;
370
+
vari;
371
+
372
+
x=empty([2,2],{
373
+
'dtype': 'float64'
374
+
});
375
+
376
+
values=[
377
+
'5',
378
+
NaN,
379
+
true,
380
+
false,
381
+
null,
382
+
void0,
383
+
{},
384
+
functionnoop(){}
385
+
];
386
+
387
+
for(i=0;i<values.length;i++){
388
+
t.throws(badValue(values[i]),TypeError,'throws an error when provided '+values[i]);
389
+
}
390
+
t.end();
391
+
392
+
functionbadValue(value){
393
+
returnfunctionbadValue(){
394
+
varopts={
395
+
'dims': value
396
+
};
397
+
findLast(x,opts,clbk);
398
+
};
399
+
}
400
+
});
401
+
402
+
tape('the function throws an error if provided an options argument with a `dims` property which contains out-of-bounds dimensions',functiontest(t){
403
+
varvalues;
404
+
varx;
405
+
vari;
406
+
407
+
x=empty([2,2],{
408
+
'dtype': 'float64'
409
+
});
410
+
411
+
values=[
412
+
[1,3],
413
+
[3,0],
414
+
[0,2]
415
+
];
416
+
417
+
for(i=0;i<values.length;i++){
418
+
t.throws(badValue(values[i]),RangeError,'throws an error when provided '+values[i]);
419
+
}
420
+
t.end();
421
+
422
+
functionbadValue(value){
423
+
returnfunctionbadValue(){
424
+
varopts={
425
+
'dims': value
426
+
};
427
+
findLast(x,opts,clbk);
428
+
};
429
+
}
430
+
});
431
+
432
+
tape('the function throws an error if provided an options argument with a `dims` property which contains duplicate dimensions',functiontest(t){
433
+
varvalues;
434
+
varx;
435
+
vari;
436
+
437
+
x=empty([2,2],{
438
+
'dtype': 'float64'
439
+
});
440
+
441
+
values=[
442
+
[0,0],
443
+
[1,1]
444
+
];
445
+
446
+
for(i=0;i<values.length;i++){
447
+
t.throws(badValue(values[i]),Error,'throws an error when provided '+values[i]);
448
+
}
449
+
t.end();
450
+
451
+
functionbadValue(value){
452
+
returnfunctionbadValue(){
453
+
varopts={
454
+
'dims': value
455
+
};
456
+
findLast(x,opts,clbk);
457
+
};
458
+
}
459
+
});
460
+
461
+
tape('the function throws an error if provided an options argument with a `dims` property which contains more dimensions than are present in the input ndarray',functiontest(t){
462
+
varvalues;
463
+
varx;
464
+
vari;
465
+
466
+
x=empty([2,2],{
467
+
'dtype': 'float64'
468
+
});
469
+
470
+
values=[
471
+
[0,1,2],
472
+
[0,1,2,3],
473
+
[0,1,2,3,4]
474
+
];
475
+
476
+
for(i=0;i<values.length;i++){
477
+
t.throws(badValue(values[i]),RangeError,'throws an error when provided '+values[i]);
478
+
}
479
+
t.end();
480
+
481
+
functionbadValue(value){
482
+
returnfunctionbadValue(){
483
+
varopts={
484
+
'dims': value
485
+
};
486
+
findLast(x,opts,clbk);
487
+
};
488
+
}
489
+
});
490
+
491
+
tape('the function throws an error if provided an options argument with an invalid `keepdims` property',functiontest(t){
492
+
varvalues;
493
+
varx;
494
+
vari;
495
+
496
+
x=empty([2,2],{
497
+
'dtype': 'float64'
498
+
});
499
+
500
+
values=[
501
+
'5',
502
+
5,
503
+
NaN,
504
+
null,
505
+
void0,
506
+
{},
507
+
[],
508
+
functionnoop(){}
509
+
];
510
+
511
+
for(i=0;i<values.length;i++){
512
+
t.throws(badValue(values[i]),TypeError,'throws an error when provided '+values[i]);
513
+
}
514
+
t.end();
515
+
516
+
functionbadValue(value){
517
+
returnfunctionbadValue(){
518
+
varopts={
519
+
'keepdims': value
520
+
};
521
+
findLast(x,opts,clbk);
522
+
};
523
+
}
524
+
});
525
+
367
526
tape('the function finds the last elements which pass a test implemented by a predicate function along one or more ndarray dimensions (row-major)',functiontest(t){
368
527
varexpected;
369
528
varactual;
@@ -597,7 +756,7 @@ tape( 'the function supports providing an execution context', function test( t )
0 commit comments