Skip to content

Commit 7fa54ea

Browse files
committed
test: add initial 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 8171fe9 commit 7fa54ea

File tree

3 files changed

+274
-0
lines changed

3 files changed

+274
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"order": "row-major",
3+
4+
"wantT": true,
5+
"wantZ": true,
6+
"kacc22": 0,
7+
"N": 4,
8+
"KTOP": 1,
9+
"KBOT": 4,
10+
"nshifts": 2,
11+
12+
"SR": [ 1.1, 2.2 ],
13+
"strideSR": 1,
14+
"offsetSR": 0,
15+
16+
"SI": [ 0.0, 0.0 ],
17+
"strideSI": 1,
18+
"offsetSI": 0,
19+
20+
"H": [ 1.0, 1.0, 0.0, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 0.0, 3.0, 2.0, 0.0, 0.0, 0.0, 4.0 ],
21+
"strideH1": 4,
22+
"strideH2": 1,
23+
"offsetH": 0,
24+
"LDH": 4,
25+
"H_mat": [
26+
[ 1.0, 1.0, 0.0, 0.0 ],
27+
[ 0.0, 2.0, 1.5, 0.0 ],
28+
[ 0.0, 0.0, 3.0, 2.0 ],
29+
[ 0.0, 0.0, 0.0, 4.0 ]
30+
],
31+
32+
"iloZ": 1,
33+
"ihiZ": 4,
34+
35+
"Z": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ],
36+
"strideZ1": 4,
37+
"strideZ2": 1,
38+
"offsetZ": 0,
39+
"LDZ": 4,
40+
"Z_mat": [
41+
[ 1.0, 0.0, 0.0, 0.0 ],
42+
[ 0.0, 1.0, 0.0, 0.0 ],
43+
[ 0.0, 0.0, 1.0, 0.0 ],
44+
[ 0.0, 0.0, 0.0, 1.0 ]
45+
],
46+
47+
"V": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
48+
"strideV1": 2,
49+
"strideV2": 1,
50+
"offsetV": 0,
51+
"LDV": 2,
52+
"V_mat": [
53+
[ 0.0, 0.0 ],
54+
[ 0.0, 0.0 ],
55+
[ 0.0, 0.0 ]
56+
],
57+
58+
"U": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
59+
"strideU1": 2,
60+
"strideU2": 1,
61+
"offsetU": 0,
62+
"LDU": 2,
63+
"U_mat": [
64+
[ 0.0, 0.0 ],
65+
[ 0.0, 0.0 ],
66+
[ 0.0, 0.0 ],
67+
[ 0.0, 0.0 ],
68+
[ 0.0, 0.0 ]
69+
],
70+
71+
"NH": 4,
72+
73+
"WH": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
74+
"strideWH1": 4,
75+
"strideWH2": 1,
76+
"offsetWH": 0,
77+
"LDWH": 4,
78+
"WH_mat": [
79+
[ 0.0, 0.0, 0.0, 0.0 ],
80+
[ 0.0, 0.0, 0.0, 0.0 ],
81+
[ 0.0, 0.0, 0.0, 0.0 ],
82+
[ 0.0, 0.0, 0.0, 0.0 ]
83+
],
84+
85+
"NV": 4,
86+
"WV": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
87+
"strideWV1": 4,
88+
"strideWV2": 1,
89+
"offsetWV": 0,
90+
"LDWV": 4,
91+
"WV_mat": [
92+
[ 0.0, 0.0, 0.0, 0.0 ],
93+
[ 0.0, 0.0, 0.0, 0.0 ],
94+
[ 0.0, 0.0, 0.0, 0.0 ],
95+
[ 0.0, 0.0, 0.0, 0.0 ]
96+
],
97+
98+
"H_out": [ 1.0, 1.0, 0.0, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 0.0, 3.0, 2.0, 0.0, 0.0, 0.0, 4.0 ],
99+
"H_out_mat": [
100+
[ 1.0, 1.0, 0.0, 0.0 ],
101+
[ 0.0, 2.0, 1.5, 0.0 ],
102+
[ 0.0, 0.0, 3.0, 2.0 ],
103+
[ 0.0, 0.0, 0.0, 4.0 ]
104+
],
105+
106+
"Z_out": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ],
107+
"Z_out_mat": [
108+
[ 1.0, 0.0, 0.0, 0.0 ],
109+
[ 0.0, 1.0, 0.0, 0.0 ],
110+
[ 0.0, 0.0, 1.0, 0.0 ],
111+
[ 0.0, 0.0, 0.0, 1.0 ]
112+
]
113+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
/* eslint-disable max-len */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var tape = require( 'tape' );
26+
var Float64Array = require( '@stdlib/array/float64' );
27+
var dlaqr5 = require( './../lib/dlaqr5.js' );
28+
29+
30+
// FIXTURES //
31+
32+
var A = require( './fixtures/a.json' );
33+
34+
35+
// TESTS //
36+
37+
tape( 'main export is a function', function test( t ) {
38+
t.ok( true, __filename );
39+
t.strictEqual( typeof dlaqr5, 'function', 'main export is a function' );
40+
t.end();
41+
});
42+
43+
tape( 'the function has an arity of 26', function test( t ) {
44+
t.strictEqual( dlaqr5.length, 26, 'returns expected value' );
45+
t.end();
46+
});
47+
48+
tape( 'the function returns expected values', function test( t ) {
49+
var expectedH;
50+
var expectedZ;
51+
var data;
52+
var WH;
53+
var WV;
54+
var SR;
55+
var SI;
56+
var H;
57+
var Z;
58+
var U;
59+
var V;
60+
61+
data = A;
62+
63+
WH = new Float64Array( data.WH );
64+
WV = new Float64Array( data.WV );
65+
H = new Float64Array( data.H );
66+
Z = new Float64Array( data.Z );
67+
U = new Float64Array( data.U );
68+
V = new Float64Array( data.V );
69+
SR = new Float64Array( data.SR );
70+
SI = new Float64Array( data.SI );
71+
expectedH = new Float64Array( data.H_out );
72+
expectedZ = new Float64Array( data.Z_out );
73+
74+
dlaqr5( data.order, data.wantT, data.wantZ, data.kacc22, data.N, data.KTOP, data.KBOT, data.nshifts, SR, SI, H, data.LDH, data.iloZ, data.ihiZ, Z, data.LDZ, V, data.LDV, U, data.LDU, data.NH, WH, data.LDWH, data.NV, WV, data.LDWV );
75+
76+
t.deepEqual( H, expectedH, 'returns expected value' );
77+
t.deepEqual( Z, expectedZ, 'returns expected value' );
78+
t.end();
79+
});
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 proxyquire = require( 'proxyquire' );
25+
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
26+
var dlaqr5 = require( './../lib' );
27+
28+
29+
// VARIABLES //
30+
31+
var opts = {
32+
'skip': IS_BROWSER
33+
};
34+
35+
36+
// TESTS //
37+
38+
tape( 'main export is a function', function test( t ) {
39+
t.ok( true, __filename );
40+
t.strictEqual( typeof dlaqr5, 'function', 'main export is a function' );
41+
t.end();
42+
});
43+
44+
tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) {
45+
t.strictEqual( typeof dlaqr5.ndarray, 'function', 'method is a function' );
46+
t.end();
47+
});
48+
49+
tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) {
50+
var dlaqr5 = proxyquire( './../lib', {
51+
'@stdlib/utils/try-require': tryRequire
52+
});
53+
54+
t.strictEqual( dlaqr5, mock, 'returns expected value' );
55+
t.end();
56+
57+
function tryRequire() {
58+
return mock;
59+
}
60+
61+
function mock() {
62+
// Mock...
63+
}
64+
});
65+
66+
tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) {
67+
var dlaqr5;
68+
var main;
69+
70+
main = require( './../lib/dlaqr5.js' );
71+
72+
dlaqr5 = proxyquire( './../lib', {
73+
'@stdlib/utils/try-require': tryRequire
74+
});
75+
76+
t.strictEqual( dlaqr5, main, 'returns expected value' );
77+
t.end();
78+
79+
function tryRequire() {
80+
return new Error( 'Cannot find module' );
81+
}
82+
});

0 commit comments

Comments
 (0)