Skip to content

Commit 51ad33f

Browse files
committed
test: add initial ndarray 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: passed - 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 fab8873 commit 51ad33f

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

lib/node_modules/@stdlib/lapack/base/dppequ/lib/ndarray.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var base = require( './base.js' );
4343
* @param {integer} strideOut - stride length for `out`
4444
* @param {integer} offsetOut - starting index for `out`
4545
* @throws {TypeError} first argument must be a valid order
46+
* @throws {RangeError} third argument must be a nonnegative integer
4647
* @returns {integer} status code
4748
*
4849
* @example
@@ -60,6 +61,9 @@ function dppequ( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, ou
6061
if ( !isLayout( order ) ) {
6162
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
6263
}
64+
if ( N < 0 ) {
65+
throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) );
66+
}
6367
return base( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, out, strideOut, offsetOut ); // eslint-disable-line max-len
6468
}
6569

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 dppequ = require( './../lib/ndarray.js' );
26+
27+
28+
// TESTS //
29+
30+
tape( 'main export is a function', function test( t ) {
31+
t.ok( true, __filename );
32+
t.strictEqual( typeof dppequ, 'function', 'main export is a function' );
33+
t.end();
34+
});
35+
36+
tape( 'the function has an arity of 12', function test( t ) {
37+
t.strictEqual( dppequ.length, 12, 'returns expected value' );
38+
t.end();
39+
});
40+
41+
tape( 'the function throws an error if provided an invalid third argument', function test( t ) {
42+
var values;
43+
var out;
44+
var AP;
45+
var S;
46+
var i;
47+
48+
values = [
49+
-1,
50+
-2,
51+
-3,
52+
-4,
53+
-5
54+
];
55+
56+
AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
57+
S = new Float64Array( 3 );
58+
out = new Float64Array( 2 );
59+
60+
for ( i = 0; i < values.length; i++ ) {
61+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
62+
}
63+
t.end();
64+
65+
function badValue( value ) {
66+
return function badValue() {
67+
dppequ( 'row-major', 'L', value, AP, 1, 0, S, 1, 0, out, 1, 0 );
68+
};
69+
}
70+
});
71+
72+
tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) {
73+
var values;
74+
var out;
75+
var AP;
76+
var S;
77+
var i;
78+
79+
values = [
80+
'foo',
81+
'bar',
82+
'beep',
83+
'boop',
84+
-5,
85+
NaN,
86+
true,
87+
false,
88+
null,
89+
void 0,
90+
[],
91+
{},
92+
function noop() {}
93+
];
94+
95+
AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] );
96+
S = new Float64Array( 3 );
97+
out = new Float64Array( 2 );
98+
99+
for ( i = 0; i < values.length; i++ ) {
100+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
101+
}
102+
t.end();
103+
104+
function badValue( value ) {
105+
return function badValue() {
106+
dppequ( value, 'L', 3, AP, 1, 0, S, 1, 0, out, 1, 0 );
107+
};
108+
}
109+
});

0 commit comments

Comments
 (0)