|
1 | 1 | /**
|
2 | 2 | * @license Apache-2.0
|
3 | 3 | *
|
4 |
| -* Copyright (c) 2018 The Stdlib Authors. |
| 4 | +* Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | *
|
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | // MODULES //
|
22 | 22 |
|
23 | 23 | var tape = require( 'tape' );
|
24 |
| -var ndarray = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
25 | 25 |
|
26 | 26 |
|
27 | 27 | // TESTS //
|
28 | 28 |
|
29 |
| -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
30 | 30 | t.ok( true, __filename );
|
31 |
| - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
32 | 32 | t.end();
|
33 | 33 | });
|
34 |
| - |
35 |
| -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { |
36 |
| - var values; |
37 |
| - var i; |
38 |
| - |
39 |
| - values = [ |
40 |
| - '5', |
41 |
| - 5, |
42 |
| - NaN, |
43 |
| - true, |
44 |
| - false, |
45 |
| - null, |
46 |
| - void 0, |
47 |
| - function noop() {} |
48 |
| - ]; |
49 |
| - |
50 |
| - for ( i = 0; i < values.length; i++ ) { |
51 |
| - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[ i ] ); |
52 |
| - } |
53 |
| - t.end(); |
54 |
| - |
55 |
| - function badValue( value ) { |
56 |
| - return function badValue() { |
57 |
| - ndarray( value ); |
58 |
| - }; |
59 |
| - } |
60 |
| -}); |
61 |
| - |
62 |
| -tape( 'the function throws an error if not provided either a `shape` or `buffer` option', function test( t ) { |
63 |
| - t.throws( badValue( {} ), Error, 'throws an error when not provided either a `shape` or `buffer` option' ); |
64 |
| - t.end(); |
65 |
| - |
66 |
| - function badValue( value ) { |
67 |
| - return function badValue() { |
68 |
| - ndarray( value ); |
69 |
| - }; |
70 |
| - } |
71 |
| -}); |
72 |
| - |
73 |
| -tape( 'the function throws an error if provided an invalid option', function test( t ) { |
74 |
| - var values; |
75 |
| - var i; |
76 |
| - |
77 |
| - values = [ |
78 |
| - '5', |
79 |
| - 'beep', |
80 |
| - 'boop', |
81 |
| - 'foo', |
82 |
| - 'bar', |
83 |
| - 5, |
84 |
| - NaN, |
85 |
| - true, |
86 |
| - false, |
87 |
| - null, |
88 |
| - void 0, |
89 |
| - [], |
90 |
| - {}, |
91 |
| - function noop() {} |
92 |
| - ]; |
93 |
| - |
94 |
| - for ( i = 0; i < values.length; i++ ) { |
95 |
| - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[ i ] ); |
96 |
| - } |
97 |
| - t.end(); |
98 |
| - |
99 |
| - function badValue( value ) { |
100 |
| - return function badValue() { |
101 |
| - var opts = { |
102 |
| - 'shape': [ 3, 2 ], |
103 |
| - 'dtype': value |
104 |
| - }; |
105 |
| - ndarray( opts ); |
106 |
| - }; |
107 |
| - } |
108 |
| -}); |
109 |
| - |
110 |
| -tape( 'the function throws an error if provided a `shape` option which is incompatible with a provided buffer', function test( t ) { |
111 |
| - var opts = { |
112 |
| - 'dtype': 'generic', |
113 |
| - 'shape': [ 3, 3 ], |
114 |
| - 'buffer': [ 1, 2, 3, 4, 5, 6 ] |
115 |
| - }; |
116 |
| - t.throws( badValue( opts ), Error, 'throws an error when provided incompatible `shape` and `buffer` options' ); |
117 |
| - t.end(); |
118 |
| - |
119 |
| - function badValue( value ) { |
120 |
| - return function badValue() { |
121 |
| - ndarray( value ); |
122 |
| - }; |
123 |
| - } |
124 |
| -}); |
125 |
| - |
126 |
| -// TODO: tests |
0 commit comments