Skip to content

Commit ede23c3

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: 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 40feafc commit ede23c3

File tree

7 files changed

+333
-4
lines changed

7 files changed

+333
-4
lines changed

lib/node_modules/@stdlib/lapack/base/dlarf1f/lib/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var dscal = require( '@stdlib/blas/base/dscal' ).ndarray;
6161
* @example
6262
* var Float64Array = require( '@stdlib/array/float64' );
6363
*
64-
* var C = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12 ] );
64+
* var C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
6565
* var V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
6666
* var work = new Float64Array( 3 );
6767
*

lib/node_modules/@stdlib/lapack/base/dlarf1f/lib/dlarf1f.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var base = require( './base.js' );
5959
* @example
6060
* var Float64Array = require( '@stdlib/array/float64' );
6161
*
62-
* var C = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12 ] );
62+
* var C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
6363
* var V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
6464
* var work = new Float64Array( 3 );
6565
*

lib/node_modules/@stdlib/lapack/base/dlarf1f/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* var Float64Array = require( '@stdlib/array/float64' );
3434
* var dlarf1f = require( '@stdlib/lapack/base/dlarf1f' );
3535
*
36-
* var C = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12 ] );
36+
* var C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
3737
* var V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
3838
* var work = new Float64Array( 3 );
3939
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var base = require( './base.js' );
5757
* @example
5858
* var Float64Array = require( '@stdlib/array/float64' );
5959
*
60-
* var C = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12 ] );
60+
* var C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
6161
* var V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
6262
* var work = new Float64Array( 3 );
6363
*
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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 dlarf1f = require( './../lib/dlarf1f.js' );
28+
29+
30+
// TESTS //
31+
32+
tape( 'main export is a function', function test( t ) {
33+
t.ok( true, __filename );
34+
t.strictEqual( typeof dlarf1f, 'function', 'main export is a function' );
35+
t.end();
36+
});
37+
38+
tape( 'the function has an arity of 10', function test( t ) {
39+
t.strictEqual( dlarf1f.length, 10, 'returns expected value' );
40+
t.end();
41+
});
42+
43+
tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) {
44+
var values;
45+
var work;
46+
var V;
47+
var C;
48+
var i;
49+
50+
C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
51+
V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
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+
dlarf1f( value, 'left', 3, 3, V, 1, 1.0, 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 V;
86+
var C;
87+
var i;
88+
89+
C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
90+
V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
91+
work = new Float64Array( 3 );
92+
93+
values = [
94+
'foo',
95+
'bar',
96+
'beep',
97+
'boop',
98+
-5,
99+
NaN,
100+
true,
101+
false,
102+
null,
103+
void 0,
104+
[],
105+
{},
106+
function noop() {}
107+
];
108+
109+
for ( i = 0; i < values.length; i++ ) {
110+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
111+
}
112+
t.end();
113+
114+
function badValue( value ) {
115+
return function badValue() {
116+
dlarf1f( 'row-major', value, 3, 3, V, 1, 1.0, C, 3, work );
117+
};
118+
}
119+
});
120+
121+
tape( 'the function throws an error if provided a ninth argument which is not a valid LDC value', function test( t ) {
122+
var values;
123+
var work;
124+
var V;
125+
var C;
126+
var i;
127+
128+
C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
129+
V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
130+
work = new Float64Array( 3 );
131+
132+
values = [
133+
0,
134+
1,
135+
2
136+
];
137+
138+
for ( i = 0; i < values.length; i++ ) {
139+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
140+
}
141+
t.end();
142+
143+
function badValue( value ) {
144+
return function badValue() {
145+
dlarf1f( 'row-major', 'left', 3, 3, V, 1, 1.0, C, value, work );
146+
};
147+
}
148+
});
149+
150+
tape( 'the function throws an error if provided a sixth argument which is not a valid incv value', function test( t ) {
151+
var work;
152+
var V;
153+
var C;
154+
155+
C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
156+
V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
157+
work = new Float64Array( 3 );
158+
159+
t.throws( badValue( 0 ), RangeError, 'throws an error when provided ' + 0 );
160+
t.end();
161+
162+
function badValue( value ) {
163+
return function badValue() {
164+
dlarf1f( 'row-major', 'left', 3, 3, V, value, 1.0, C, 3, work );
165+
};
166+
}
167+
});
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 dlarf1f = 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 dlarf1f, '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 dlarf1f.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 dlarf1f = proxyquire( './../lib', {
51+
'@stdlib/utils/try-require': tryRequire
52+
});
53+
54+
t.strictEqual( dlarf1f, 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 dlarf1f;
68+
var main;
69+
70+
main = require( './../lib/dlarf1f.js' );
71+
72+
dlarf1f = proxyquire( './../lib', {
73+
'@stdlib/utils/try-require': tryRequire
74+
});
75+
76+
t.strictEqual( dlarf1f, main, 'returns expected value' );
77+
t.end();
78+
79+
function tryRequire() {
80+
return new Error( 'Cannot find module' );
81+
}
82+
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 dlarf1f = require( './../lib/ndarray.js' );
28+
29+
30+
// TESTS //
31+
32+
tape( 'main export is a function', function test( t ) {
33+
t.ok( true, __filename );
34+
t.strictEqual( typeof dlarf1f, 'function', 'main export is a function' );
35+
t.end();
36+
});
37+
38+
tape( 'the function has an arity of 14', function test( t ) {
39+
t.strictEqual( dlarf1f.length, 14, 'returns expected value' );
40+
t.end();
41+
});
42+
43+
tape( 'the function throws an error if provided a first argument which is not a valid side', function test( t ) {
44+
var values;
45+
var work;
46+
var V;
47+
var C;
48+
var i;
49+
50+
C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
51+
V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] );
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+
dlarf1f( 'row-major', value, 3, 3, V, 1, 1.0, C, 3, work );
78+
};
79+
}
80+
});

0 commit comments

Comments
 (0)