Skip to content

Commit 74f687e

Browse files
committed
Auto-generated commit
1 parent 5dfb632 commit 74f687e

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ A total of 7 people contributed to this release. Thank you to the following cont
10871087

10881088
<details>
10891089

1090+
- [`70d0be2`](https://github.com/stdlib-js/stdlib/commit/70d0be235297eecc69d8e7ec4aad484ac7d5aedc) - **test:** add 0d tests _(by Athan Reines)_
10901091
- [`d761114`](https://github.com/stdlib-js/stdlib/commit/d761114ce6f6f74f0befb8c445e4632c0265c150) - **docs:** update descriptions _(by Athan Reines)_
10911092
- [`59ab26d`](https://github.com/stdlib-js/stdlib/commit/59ab26d220e5950d2a4e1fa087602e73ce3e3b5b) - **docs:** add `c_x_as_z_x` example _(by Athan Reines)_
10921093
- [`ae76c53`](https://github.com/stdlib-js/stdlib/commit/ae76c53f6559c382a9843c62f2b767b59e2554d9) - **docs:** add `z_x` example _(by Athan Reines)_

base/every/test/test.0d.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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 Float64Array = require( '@stdlib/array/float64' );
25+
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
26+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
27+
var scalar2ndarray = require( './../../../from-scalar' );
28+
var ndarray = require( './../../../ctor' );
29+
var every = require( './../lib' );
30+
31+
32+
// TESTS //
33+
34+
tape( 'main export is a function', function test( t ) {
35+
t.ok( true, __filename );
36+
t.strictEqual( typeof every, 'function', 'main export is a function');
37+
t.end();
38+
});
39+
40+
tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy', function test( t ) {
41+
var actual;
42+
var x;
43+
44+
x = scalar2ndarray( 0.0, {
45+
'dtype': 'float64'
46+
});
47+
48+
actual = every( [ x ] );
49+
t.strictEqual( actual, false, 'returns expected value' );
50+
51+
x = scalar2ndarray( 1.0, {
52+
'dtype': 'float64'
53+
});
54+
55+
actual = every( [ x ] );
56+
t.strictEqual( actual, true, 'returns expected value' );
57+
58+
t.end();
59+
});
60+
61+
tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy (accessors)', function test( t ) {
62+
var actual;
63+
var x;
64+
65+
x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 0.0 ] ) ), [], [ 0 ], 0, 'row-major' );
66+
67+
actual = every( [ x ] );
68+
t.strictEqual( actual, false, 'returns expected value' );
69+
70+
x = ndarray( 'float64', toAccessorArray( new Float64Array( [ 1.0 ] ) ), [], [ 0 ], 0, 'row-major' );
71+
72+
actual = every( [ x ] );
73+
t.strictEqual( actual, true, 'returns expected value' );
74+
75+
t.end();
76+
});
77+
78+
tape( 'the function tests whether every element in a 0-dimensional ndarray is truthy (complex)', function test( t ) {
79+
var actual;
80+
var x;
81+
82+
x = scalar2ndarray( new Complex128( 0.0, 0.0 ), {
83+
'dtype': 'complex128'
84+
});
85+
86+
actual = every( [ x ] );
87+
t.strictEqual( actual, false, 'returns expected value' );
88+
89+
x = scalar2ndarray( new Complex128( 1.0, 0.0 ), {
90+
'dtype': 'complex128'
91+
});
92+
93+
actual = every( [ x ] );
94+
t.strictEqual( actual, true, 'returns expected value' );
95+
96+
t.end();
97+
});

0 commit comments

Comments
 (0)