-
-
Notifications
You must be signed in to change notification settings - Fork 860
test: add missing tests to ndarray/base/every
#7235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8537fc1
test: add 1d tests
headlessNode fa882bd
test: add 2d tests
headlessNode d56c204
chore: fix comment
headlessNode 7f886c4
fix: data type
headlessNode 4b84791
fix: coverage
headlessNode bfabd7d
refactor: apply suggestions from code review
headlessNode d28a6af
fix: import
headlessNode 144325b
fix: apply suggestions from code review
headlessNode 0a9930c
feat: add 3d tests
headlessNode e7d4207
feat: add 4d tests
headlessNode 020a50b
feat: add 5d tests
headlessNode 1e9f123
feat: add 6d tests
headlessNode ff52fc3
feat: add 7d tests
headlessNode 756302d
feat: add 8d tests
headlessNode 753bc91
feat: add 9d tests
headlessNode 786cb72
feat: add 10d tests
headlessNode af74100
feat: add nd tests
headlessNode 6a87744
feat: add empty array case
headlessNode b61bb96
fix: order
headlessNode 1dd55b5
fix: apply suggestions from code review
headlessNode 8ee084f
fix: noncontiguous strides
headlessNode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
lib/node_modules/@stdlib/ndarray/base/every/test/test.1d.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2025 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var tape = require( 'tape' ); | ||
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); | ||
var zeros = require( '@stdlib/array/zeros' ); | ||
var ones = require( '@stdlib/array/ones' ); | ||
var ndarray = require( '@stdlib/ndarray/ctor' ); | ||
var every = require( './../lib' ); | ||
|
||
|
||
// TESTS // | ||
|
||
tape( 'main export is a function', function test( t ) { | ||
t.ok( true, __filename ); | ||
t.strictEqual( typeof every, 'function', 'main export is a function'); | ||
t.end(); | ||
}); | ||
|
||
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy', function test( t ) { | ||
var actual; | ||
var x; | ||
|
||
x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); | ||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, false, 'returns expected value' ); | ||
|
||
x = ndarray( 'float64', ones( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); | ||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, true, 'returns expected value' ); | ||
|
||
t.end(); | ||
}); | ||
|
||
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy (accessors)', function test( t ) { | ||
var actual; | ||
var x; | ||
|
||
x = ndarray( 'float64', toAccessorArray( zeros( 8, 'float64' ) ), [ 4 ], [ 2 ], 1, 'row-major' ); | ||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, false, 'returns expected value' ); | ||
|
||
x = ndarray( 'float64', toAccessorArray( ones( 8, 'float64' ) ), [ 4 ], [ 2 ], 1, 'row-major' ); | ||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, true, 'returns expected value' ); | ||
|
||
t.end(); | ||
}); | ||
|
||
tape( 'the function tests whether every element in a 1-dimensional ndarray is truthy (complex)', function test( t ) { | ||
var actual; | ||
var x; | ||
|
||
x = ndarray( 'complex128', toAccessorArray( zeros( 6, 'complex128' ) ), [ 4 ], [ 1 ], 1, 'row-major' ); | ||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, false, 'returns expected value' ); | ||
|
||
x = ndarray( 'complex128', toAccessorArray( ones( 6, 'complex128' ) ), [ 4 ], [ 1 ], 1, 'row-major' ); | ||
headlessNode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
actual = every( [ x ] ); | ||
t.strictEqual( actual, true, 'returns expected value' ); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.