Skip to content

Commit b479fcf

Browse files
authored
test: add missing tests to ndarray/base/every
PR-URL: #7235 Ref: #2656 Reviewed-by: Athan Reines <[email protected]>
1 parent 0e13713 commit b479fcf

File tree

12 files changed

+18668
-0
lines changed

12 files changed

+18668
-0
lines changed

lib/node_modules/@stdlib/ndarray/base/every/test/test.10d.js

Lines changed: 2949 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
25+
var zeros = require( '@stdlib/array/zeros' );
26+
var ones = require( '@stdlib/array/ones' );
27+
var ndarray = require( '@stdlib/ndarray/ctor' );
28+
var every = require( './../lib' );
29+
30+
31+
// TESTS //
32+
33+
tape( 'main export is a function', function test( t ) {
34+
t.ok( true, __filename );
35+
t.strictEqual( typeof every, 'function', 'main export is a function');
36+
t.end();
37+
});
38+
39+
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy', function test( t ) {
40+
var actual;
41+
var x;
42+
43+
x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' );
44+
45+
actual = every( [ x ] );
46+
t.strictEqual( actual, false, 'returns expected value' );
47+
48+
x = ndarray( 'float64', ones( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' );
49+
50+
actual = every( [ x ] );
51+
t.strictEqual( actual, true, 'returns expected value' );
52+
53+
t.end();
54+
});
55+
56+
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy (accessors)', function test( t ) {
57+
var actual;
58+
var x;
59+
60+
x = ndarray( 'float64', toAccessorArray( zeros( 8, 'float64' ) ), [ 4 ], [ 2 ], 1, 'row-major' );
61+
62+
actual = every( [ x ] );
63+
t.strictEqual( actual, false, 'returns expected value' );
64+
65+
x = ndarray( 'float64', toAccessorArray( ones( 8, 'float64' ) ), [ 4 ], [ 2 ], 1, 'row-major' );
66+
67+
actual = every( [ x ] );
68+
t.strictEqual( actual, true, 'returns expected value' );
69+
70+
t.end();
71+
});
72+
73+
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy (complex)', function test( t ) {
74+
var actual;
75+
var x;
76+
77+
x = ndarray( 'complex128', zeros( 6, 'complex128' ), [ 4 ], [ 1 ], 1, 'row-major' );
78+
79+
actual = every( [ x ] );
80+
t.strictEqual( actual, false, 'returns expected value' );
81+
82+
x = ndarray( 'complex128', ones( 6, 'complex128' ), [ 4 ], [ 1 ], 1, 'row-major' );
83+
84+
actual = every( [ x ] );
85+
t.strictEqual( actual, true, 'returns expected value' );
86+
87+
t.end();
88+
});

0 commit comments

Comments
 (0)