Skip to content

Commit ab20a97

Browse files
committed
Update tests
1 parent 3caa788 commit ab20a97

File tree

2 files changed

+56
-40
lines changed

2 files changed

+56
-40
lines changed

lib/node_modules/@stdlib/blas/base/gscal/test/test.main.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ tape( 'the function has an arity of 4', function test( t ) {
4040

4141
tape( 'the function multiplies `x` by a constant', function test( t ) {
4242
var expected;
43-
var alpha;
4443
var x;
4544

46-
alpha = 5.0;
4745
x = [
4846
4.0,
4947
2.0,
@@ -65,14 +63,13 @@ tape( 'the function multiplies `x` by a constant', function test( t ) {
6563
30.0
6664
];
6765

68-
gscal( x.length, alpha, x, 1 );
66+
gscal( x.length, 5.0, x, 1 );
6967
t.deepEqual( x, expected, 'returns expected value' );
7068

71-
// Short datasets:
7269
x = [ 1.0, 2.0 ];
7370
expected = [ 5.0, 10.0 ];
7471

75-
gscal( x.length, alpha, x, 1 );
72+
gscal( x.length, 5.0, x, 1 );
7673
t.deepEqual( x, expected, 'returns expected value' );
7774

7875
t.end();
@@ -91,40 +88,35 @@ tape( 'the function returns a reference to the input array', function test( t )
9188

9289
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) {
9390
var expected;
94-
var alpha;
9591
var x;
9692

97-
alpha = 5.0;
9893
x = [ 3.0, -4.0, 1.0 ];
9994
expected = [ 3.0, -4.0, 1.0 ];
10095

101-
gscal( 0, alpha, x, 1 );
96+
gscal( 0, 5.0, x, 1 );
10297
t.deepEqual( x, expected, 'returns expected value' );
10398

104-
gscal( -4, alpha, x, 1 );
99+
gscal( -4, 5.0, x, 1 );
105100
t.deepEqual( x, expected, 'returns expected value' );
106101

107102
t.end();
108103
});
109104

110105
tape( 'if `alpha` equals `1`, the function returns `x` unchanged', function test( t ) {
111106
var expected;
112-
var alpha;
113107
var x;
114108

115-
alpha = 1.0;
116109
x = [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ];
117110
expected = [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ];
118111

119-
gscal( x.length, alpha, x, 1 );
112+
gscal( x.length, 1.0, x, 1 );
120113
t.deepEqual( x, expected, 'returns expected value' );
121114

122115
t.end();
123116
});
124117

125118
tape( 'the function supports specifying a stride', function test( t ) {
126119
var expected;
127-
var alpha;
128120
var x;
129121

130122
x = [
@@ -142,19 +134,32 @@ tape( 'the function supports specifying a stride', function test( t ) {
142134
30.0 // 2
143135
];
144136

145-
alpha = 5.0;
146-
gscal( 3, alpha, x, 2 );
137+
gscal( 3, 5.0, x, 2 );
147138
t.deepEqual( x, expected, 'returns expected value' );
148139
t.end();
149140
});
150141

142+
tape( 'if provided a `stride` less than or equal to `0`, the function returns `x` unchanged', function test( t ) {
143+
var expected;
144+
var x;
145+
146+
x = [ 3.0, -4.0, 1.0 ];
147+
expected = [ 3.0, -4.0, 1.0 ];
148+
149+
gscal( x.length, 5.0, x, 0 );
150+
t.deepEqual( x, expected, 'returns expected value' );
151+
152+
gscal( x.length, 5.0, x, -1 );
153+
t.deepEqual( x, expected, 'returns expected value' );
154+
155+
t.end();
156+
});
157+
151158
tape( 'the function supports view offsets', function test( t ) {
152159
var expected;
153-
var alpha;
154160
var x0;
155161
var x1;
156162

157-
alpha = 5.0;
158163
x0 = new Float64Array([
159164
1.0,
160165
2.0, // 0
@@ -173,7 +178,7 @@ tape( 'the function supports view offsets', function test( t ) {
173178

174179
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
175180

176-
gscal( 3, alpha, x1, 2 );
181+
gscal( 3, 5.0, x1, 2 );
177182
t.deepEqual( x1, expected, 'returns expected value' );
178183
t.end();
179184
});

lib/node_modules/@stdlib/blas/base/gscal/test/test.ndarray.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ tape( 'the function has an arity of 5', function test( t ) {
4040

4141
tape( 'the function multiplies `x` by a constant', function test( t ) {
4242
var expected;
43-
var alpha;
4443
var x;
4544

46-
alpha = 5.0;
4745
x = [
4846
4.0,
4947
2.0,
@@ -65,14 +63,13 @@ tape( 'the function multiplies `x` by a constant', function test( t ) {
6563
30.0
6664
];
6765

68-
gscal( x.length, alpha, x, 1, 0 );
66+
gscal( x.length, 5.0, x, 1, 0 );
6967
t.deepEqual( x, expected, 'returns expected value' );
7068

71-
// Short datasets:
72-
x = new Float64Array( [ 1.0, 2.0 ] );
73-
expected = new Float64Array( [ 5.0, 10.0 ] );
69+
x = [ 1.0, 2.0 ];
70+
expected = [ 5.0, 10.0 ];
7471

75-
gscal( x.length, alpha, x, 1, 0 );
72+
gscal( x.length, 5.0, x, 1, 0 );
7673
t.deepEqual( x, expected, 'returns expected value' );
7774

7875
t.end();
@@ -91,40 +88,35 @@ tape( 'the function returns a reference to the input array', function test( t )
9188

9289
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) {
9390
var expected;
94-
var alpha;
9591
var x;
9692

97-
alpha = 1.0;
9893
x = [ 3.0, -4.0, 1.0 ];
9994
expected = [ 3.0, -4.0, 1.0 ];
10095

101-
gscal( 0, alpha, x, 1, 0 );
96+
gscal( 0, 10.0, x, 1, 0 );
10297
t.deepEqual( x, expected, 'returns expected value' );
10398

104-
gscal( -4, alpha, x, 1, 0 );
99+
gscal( -4, 10.0, x, 1, 0 );
105100
t.deepEqual( x, expected, 'returns expected value' );
106101

107102
t.end();
108103
});
109104

110105
tape( 'if `alpha` equals `1`, the function returns `x` unchanged', function test( t ) {
111106
var expected;
112-
var alpha;
113107
var x;
114108

115-
alpha = 1.0;
116109
x = [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ];
117110
expected = [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ];
118111

119-
gscal( x.length, alpha, x, 1, 0 );
112+
gscal( x.length, 1.0, x, 1, 0 );
120113
t.deepEqual( x, expected, 'returns expected value' );
121114

122115
t.end();
123116
});
124117

125118
tape( 'the function supports specifying a stride', function test( t ) {
126119
var expected;
127-
var alpha;
128120
var x;
129121

130122
x = [
@@ -142,20 +134,39 @@ tape( 'the function supports specifying a stride', function test( t ) {
142134
30.0 // 2
143135
];
144136

145-
alpha = 5.0;
146-
gscal( 3, alpha, x, 2, 0 );
137+
gscal( 3, 5.0, x, 2, 0 );
138+
t.deepEqual( x, expected, 'returns expected value' );
139+
t.end();
140+
});
141+
142+
tape( 'the function supports specifying a negative stride', function test( t ) {
143+
var expected;
144+
var x;
145+
146+
x = [
147+
2.0, // 2
148+
-3.0,
149+
-5.0, // 1
150+
7.0,
151+
6.0 // 0
152+
];
153+
expected = [
154+
10.0, // 0
155+
-3.0,
156+
-25.0, // 1
157+
7.0,
158+
30.0 // 2
159+
];
160+
161+
gscal( 3, 5.0, x, -2, x.length-1 );
147162
t.deepEqual( x, expected, 'returns expected value' );
148163
t.end();
149164
});
150165

151166
tape( 'the function supports an offset parameter', function test( t ) {
152167
var expected;
153-
var offset;
154-
var alpha;
155168
var x;
156169

157-
alpha = 5.0;
158-
offset = 1;
159170
x = [
160171
1.0,
161172
2.0, // 0
@@ -173,7 +184,7 @@ tape( 'the function supports an offset parameter', function test( t ) {
173184
30.0
174185
];
175186

176-
gscal( 3, alpha, x, 2, offset );
187+
gscal( 3, 5.0, x, 2, 1 );
177188
t.deepEqual( x, expected, 'returns expected value' );
178189
t.end();
179190
});

0 commit comments

Comments
 (0)