Skip to content

Commit 871e7fc

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 caff697 commit 871e7fc

File tree

5 files changed

+572
-0
lines changed

5 files changed

+572
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"order": "column-major",
3+
"side": "left",
4+
"trans": "no-transpose",
5+
"M": 3,
6+
"N": 3,
7+
"K": 3,
8+
9+
"A_mat": [
10+
[ 1.0, 2.0, 3.0 ],
11+
[ 0.0, 4.0, 5.0 ],
12+
[ 0.0, 0.0, 6.0 ]
13+
],
14+
"LDA": 3,
15+
"strideA1": 1,
16+
"strideA2": 3,
17+
"offsetA": 0,
18+
"A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ],
19+
20+
"tau": [ 7.0, 8.0, 9.0 ],
21+
"strideTau": 1,
22+
"offsetTau": 0,
23+
24+
"C_mat": [
25+
[ 1.0, 4.0, 7.0 ],
26+
[ 2.0, 5.0, 8.0 ],
27+
[ 3.0, 6.0, 9.0 ]
28+
],
29+
"LDC": 3,
30+
"strideC1": 1,
31+
"strideC2": 3,
32+
"offsetC": 0,
33+
"C": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ],
34+
35+
"work": [ 0.0, 0.0, 0.0 ],
36+
"strideWork": 1,
37+
"offsetWork": 0,
38+
39+
"C_out_mat": [
40+
[ -261638.0, -521066.0, -773933.0 ],
41+
[ -298618.0, -594715.0, -883324.0 ],
42+
[ -335598.0, -668364.0, -992715.0 ]
43+
],
44+
"C_out": [ -261638.0, -298618.0, -335598.0, -521066.0, -594715.0, -668364.0, -773933.0, -883324.0, -992715.0 ]
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"order": "row-major",
3+
"side": "left",
4+
"trans": "no-transpose",
5+
"M": 3,
6+
"N": 3,
7+
"K": 3,
8+
9+
"A_mat": [
10+
[ 1.0, 0.0, 0.0 ],
11+
[ 2.0, 4.0, 0.0 ],
12+
[ 3.0, 5.0, 6.0 ]
13+
],
14+
"LDA": 3,
15+
"strideA1": 3,
16+
"strideA2": 1,
17+
"offsetA": 0,
18+
"A": [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ],
19+
20+
"tau": [ 7.0, 8.0, 9.0 ],
21+
"strideTau": 1,
22+
"offsetTau": 0,
23+
24+
"C_mat": [
25+
[ 1.0, 2.0, 3.0 ],
26+
[ 4.0, 5.0, 6.0 ],
27+
[ 7.0, 8.0, 9.0 ]
28+
],
29+
"LDC": 3,
30+
"strideC1": 3,
31+
"strideC2": 1,
32+
"offsetC": 0,
33+
"C": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ],
34+
35+
"work": [ 0.0, 0.0, 0.0 ],
36+
"strideWork": 1,
37+
"offsetWork": 0,
38+
39+
"C_out_mat": [
40+
[ -261638.0, -298618.0, -335598.0 ],
41+
[ -521066.0, -594715.0, -668364.0 ],
42+
[ -773933.0, -883324.0, -992715.0 ]
43+
],
44+
"C_out": [ -261638.0, -298618.0, -335598.0, -521066.0, -594715.0, -668364.0, -773933.0, -883324.0, -992715.0 ]
45+
}
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
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 dorm2r = require( './../lib/dorm2r.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 dorm2r, '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( dorm2r.length, 12, 'returns expected value' );
38+
t.end();
39+
});
40+
41+
tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) {
42+
var values;
43+
var work;
44+
var tau;
45+
var A;
46+
var C;
47+
var i;
48+
49+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
50+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
51+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
52+
work = new Float64Array( 3 );
53+
54+
values = [
55+
'foo',
56+
'bar',
57+
'beep',
58+
'boop',
59+
-5,
60+
NaN,
61+
true,
62+
false,
63+
null,
64+
void 0,
65+
[],
66+
{},
67+
function noop() {}
68+
];
69+
70+
for ( i = 0; i < values.length; i++ ) {
71+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
72+
}
73+
t.end();
74+
75+
function badValue( value ) {
76+
return function badValue() {
77+
dorm2r( value, 'left', 'no-transpose', 3, 3, 3, A, 3, tau, C, 3, work );
78+
};
79+
}
80+
});
81+
82+
tape( 'the function throws an error if provided a second argument which is not a valid side', function test( t ) {
83+
var values;
84+
var work;
85+
var tau;
86+
var A;
87+
var C;
88+
var i;
89+
90+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
91+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
92+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
93+
work = new Float64Array( 3 );
94+
95+
values = [
96+
'foo',
97+
'bar',
98+
'beep',
99+
'boop',
100+
-5,
101+
NaN,
102+
true,
103+
false,
104+
null,
105+
void 0,
106+
[],
107+
{},
108+
function noop() {}
109+
];
110+
111+
for ( i = 0; i < values.length; i++ ) {
112+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
113+
}
114+
t.end();
115+
116+
function badValue( value ) {
117+
return function badValue() {
118+
dorm2r( 'row-major', value, 'no-transpose', 3, 3, 3, A, 3, tau, C, 3, work );
119+
};
120+
}
121+
});
122+
123+
tape( 'the function throws an error if provided a third argument which is not a valid trans', function test( t ) {
124+
var values;
125+
var work;
126+
var tau;
127+
var A;
128+
var C;
129+
var i;
130+
131+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
132+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
133+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
134+
work = new Float64Array( 3 );
135+
136+
values = [
137+
'foo',
138+
'bar',
139+
'beep',
140+
'boop',
141+
-5,
142+
NaN,
143+
true,
144+
false,
145+
null,
146+
void 0,
147+
[],
148+
{},
149+
function noop() {}
150+
];
151+
152+
for ( i = 0; i < values.length; i++ ) {
153+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
154+
}
155+
t.end();
156+
157+
function badValue( value ) {
158+
return function badValue() {
159+
dorm2r( 'row-major', 'left', value, 3, 3, 3, A, 3, tau, C, 3, work );
160+
};
161+
}
162+
});
163+
164+
tape( 'the function throws an error if provided an eighth argument which is not a valid `LDA` value (row-major)', function test( t ) {
165+
var values;
166+
var work;
167+
var tau;
168+
var A;
169+
var C;
170+
var i;
171+
172+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
173+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
174+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
175+
work = new Float64Array( 3 );
176+
177+
values = [
178+
-1,
179+
0,
180+
NaN,
181+
'5',
182+
null,
183+
void 0,
184+
true,
185+
false,
186+
[],
187+
{},
188+
function noop() {}
189+
];
190+
191+
for ( i = 0; i < values.length; i++ ) {
192+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
193+
}
194+
t.end();
195+
196+
function badValue( value ) {
197+
return function badValue() {
198+
dorm2r( 'row-major', 'left', 'no-transpose', 3, 3, 3, A, value, tau, C, 3, work );
199+
};
200+
}
201+
});
202+
203+
tape( 'the function throws an error if provided a twelfth argument which is not a valid `LDC` value (row-major)', function test( t ) {
204+
var values;
205+
var work;
206+
var tau;
207+
var A;
208+
var C;
209+
var i;
210+
211+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
212+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
213+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
214+
work = new Float64Array( 3 );
215+
216+
values = [
217+
-1,
218+
0,
219+
NaN,
220+
'5',
221+
null,
222+
void 0,
223+
true,
224+
false,
225+
[],
226+
{},
227+
function noop() {}
228+
];
229+
230+
for ( i = 0; i < values.length; i++ ) {
231+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
232+
}
233+
t.end();
234+
235+
function badValue( value ) {
236+
return function badValue() {
237+
dorm2r( 'row-major', 'left', 'no-transpose', 3, 3, 3, A, 3, tau, C, value, work );
238+
};
239+
}
240+
});
241+
242+
tape( 'the function throws an error if provided a twelfth argument which is not a valid `LDC` value (column-major)', function test( t ) {
243+
var values;
244+
var work;
245+
var tau;
246+
var A;
247+
var C;
248+
var i;
249+
250+
A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] );
251+
tau = new Float64Array( [ 7.0, 8.0, 9.0 ] );
252+
C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] );
253+
work = new Float64Array( 3 );
254+
255+
values = [
256+
-1,
257+
0,
258+
NaN,
259+
'5',
260+
null,
261+
void 0,
262+
true,
263+
false,
264+
[],
265+
{},
266+
function noop() {}
267+
];
268+
269+
for ( i = 0; i < values.length; i++ ) {
270+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
271+
}
272+
t.end();
273+
274+
function badValue( value ) {
275+
return function badValue() {
276+
dorm2r( 'column-major', 'left', 'no-transpose', 3, 3, 3, A, 3, tau, C, value, work );
277+
};
278+
}
279+
});

0 commit comments

Comments
 (0)