Skip to content

Commit c57f065

Browse files
committed
test: update tests
1 parent 4914f67 commit c57f065

File tree

1 file changed

+31
-26
lines changed
  • lib/node_modules/@stdlib/ndarray/map/test

1 file changed

+31
-26
lines changed

lib/node_modules/@stdlib/ndarray/map/test/test.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tape( 'main export is a function', function test( t ) {
4444
t.end();
4545
});
4646

47-
tape( 'the function throws an error if provided a first argument having an unrecognized data type', function test( t ) {
47+
tape( 'the function throws an error if provided a first argument which is not an ndarray', function test( t ) {
4848
var values;
4949
var i;
5050

@@ -68,18 +68,18 @@ tape( 'the function throws an error if provided a first argument having an unrec
6868
}
6969
t.end();
7070

71-
function scale( z ) {
72-
return z * 10.0;
73-
}
74-
7571
function badValue( value ) {
7672
return function badValue() {
7773
map( value, scale );
7874
};
7975
}
76+
77+
function scale( z ) {
78+
return z * 10.0;
79+
}
8080
});
8181

82-
tape( 'the function throws an error if the second argument is not a function', function test( t ) {
82+
tape( 'the function throws an error if a callback argument which is not a function', function test( t ) {
8383
var values;
8484
var x;
8585
var i;
@@ -108,7 +108,7 @@ tape( 'the function throws an error if the second argument is not a function', f
108108
}
109109
});
110110

111-
tape( 'the function throws an error if third argument is not a function (options)', function test( t ) {
111+
tape( 'the function throws an error if callback argument which is not a function (options)', function test( t ) {
112112
var values;
113113
var opts;
114114
var x;
@@ -163,32 +163,34 @@ tape( 'the function throws an error if provided an options argument which is not
163163
}
164164
t.end();
165165

166-
function scale( z ) {
167-
return z * 10.0;
168-
}
169-
170166
function badValue( value ) {
171167
return function badValue() {
172168
map( x, value, scale );
173169
};
174170
}
171+
172+
function scale( z ) {
173+
return z * 10.0;
174+
}
175175
});
176176

177-
tape( 'the function throws an error if the provided options argument does not have a `dtype` property', function test( t ) {
177+
tape( 'the function throws an error if provided an invalid `dtype` option', function test( t ) {
178178
var values;
179179
var x;
180180
var i;
181181

182182
values = [
183-
{
184-
'order': 'column-major'
185-
},
186-
{
187-
'shape': [ 3, 1 ]
188-
},
189-
{
190-
'strides': [ 1, 3 ]
191-
}
183+
'foo',
184+
'bar',
185+
1,
186+
NaN,
187+
true,
188+
false,
189+
void 0,
190+
null,
191+
[],
192+
{},
193+
function noop() {}
192194
];
193195
x = ndarray( 'generic', ones( 4, 'generic' ), [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
194196

@@ -197,15 +199,18 @@ tape( 'the function throws an error if the provided options argument does not ha
197199
}
198200
t.end();
199201

200-
function scale( z ) {
201-
return z * 10.0;
202-
}
203-
204202
function badValue( value ) {
205203
return function badValue() {
206-
map( x, value, scale );
204+
var opts = {
205+
'dtype': value
206+
};
207+
map( x, opts, scale );
207208
};
208209
}
210+
211+
function scale( z ) {
212+
return z * 10.0;
213+
}
209214
});
210215

211216
tape( 'the function applies a callback to each indexed element in an input ndarray and returns an output ndarray with mapped values (row-major, contiguous)', function test( t ) {

0 commit comments

Comments
 (0)