Skip to content

Commit 3d3ff82

Browse files
committed
feat: add missing tests
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 84cf373 commit 3d3ff82

File tree

2 files changed

+1527
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)