|
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 | vartape=require('tape'); |
24 | | -varndarray=require('./../../dist'); |
| 24 | +varmain=require('./../../dist'); |
25 | 25 |
|
26 | 26 |
|
27 | 27 | // TESTS // |
28 | 28 |
|
29 | | -tape('main export isa function',functiontest(t){ |
| 29 | +tape('main export isdefined',functiontest(t){ |
30 | 30 | t.ok(true,__filename); |
31 | | -t.strictEqual(typeofndarray,'function','main export isa function'); |
| 31 | +t.strictEqual(main!==void0,true,'main export isdefined'); |
32 | 32 | t.end(); |
33 | 33 | }); |
34 | | - |
35 | | -tape('the function throws an error if provided an options argument which is not an object',functiontest(t){ |
36 | | -varvalues; |
37 | | -vari; |
38 | | - |
39 | | -values=[ |
40 | | -'5', |
41 | | -5, |
42 | | -NaN, |
43 | | -true, |
44 | | -false, |
45 | | -null, |
46 | | -void0, |
47 | | -functionnoop(){} |
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 | | -functionbadValue(value){ |
56 | | -returnfunctionbadValue(){ |
57 | | -ndarray(value); |
58 | | -}; |
59 | | -} |
60 | | -}); |
61 | | - |
62 | | -tape('the function throws an error if not provided either a `shape` or `buffer` option',functiontest(t){ |
63 | | -t.throws(badValue({}),Error,'throws an error when not provided either a `shape` or `buffer` option'); |
64 | | -t.end(); |
65 | | - |
66 | | -functionbadValue(value){ |
67 | | -returnfunctionbadValue(){ |
68 | | -ndarray(value); |
69 | | -}; |
70 | | -} |
71 | | -}); |
72 | | - |
73 | | -tape('the function throws an error if provided an invalid option',functiontest(t){ |
74 | | -varvalues; |
75 | | -vari; |
76 | | - |
77 | | -values=[ |
78 | | -'5', |
79 | | -'beep', |
80 | | -'boop', |
81 | | -'foo', |
82 | | -'bar', |
83 | | -5, |
84 | | -NaN, |
85 | | -true, |
86 | | -false, |
87 | | -null, |
88 | | -void0, |
89 | | -[], |
90 | | -{}, |
91 | | -functionnoop(){} |
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 | | -functionbadValue(value){ |
100 | | -returnfunctionbadValue(){ |
101 | | -varopts={ |
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',functiontest(t){ |
111 | | -varopts={ |
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 | | -functionbadValue(value){ |
120 | | -returnfunctionbadValue(){ |
121 | | -ndarray(value); |
122 | | -}; |
123 | | -} |
124 | | -}); |
125 | | - |
126 | | -// TODO: tests |