Skip to content

Commit 138713e

Browse files
committed
test: improve test coverage
--- 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 dca66e9 commit 138713e

File tree

7 files changed

+168
-2
lines changed

7 files changed

+168
-2
lines changed

lib/node_modules/@stdlib/math/base/special/sinpif/test/fixtures/julia/large_negative.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/sinpif/test/fixtures/julia/large_positive.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/sinpif/test/fixtures/julia/runner.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,19 @@ gen( x, "integers.json" );
6868
# Decimal values:
6969
x = Float32.( range( -100, stop = 100, length = 2003 ) );
7070
gen( x, "decimals.json" );
71+
72+
# Small positive values:
73+
x = Float32.( range( 2.0^-18, stop = 2.0^-14, length = 2001 ) );
74+
gen( x, "small_positive.json" );
75+
76+
# Small negative values:
77+
x = Float32.( range( -2.0^-14, stop = -2.0^-18, length = 2001 ) );
78+
gen( x, "small_negative.json" );
79+
80+
# Large positive values:
81+
x = Float32.( range( 2.0^23, stop = 2.0^30, length = 2001 ) );
82+
gen( x, "large_positive.json" );
83+
84+
# Large negative values:
85+
x = Float32.( range( -2.0^30, stop = -2.0^23, length = 2001 ) );
86+
gen( x, "large_negative.json" );

lib/node_modules/@stdlib/math/base/special/sinpif/test/fixtures/julia/small_negative.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/sinpif/test/fixtures/julia/small_positive.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/sinpif/test/test.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2525
var PINF = require( '@stdlib/constants/float32/pinf' );
2626
var NINF = require( '@stdlib/constants/float32/ninf' );
2727
var f32 = require( '@stdlib/number/float64/base/to-float32' );
28+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
2829
var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
2930
var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' );
3031
var isSameValue = require( '@stdlib/assert/is-same-value' );
@@ -35,6 +36,10 @@ var sinpif = require( './../lib/' );
3536

3637
var integers = require( './fixtures/julia/integers.json' );
3738
var decimals = require( './fixtures/julia/decimals.json' );
39+
var smallPositive = require( './fixtures/julia/small_positive.json' );
40+
var smallNegative = require( './fixtures/julia/small_negative.json' );
41+
var largePositive = require( './fixtures/julia/large_positive.json' );
42+
var largeNegative = require( './fixtures/julia/large_negative.json' );
3843

3944

4045
// TESTS //
@@ -103,7 +108,7 @@ tape( 'the function is odd', function test( t ) {
103108
t.end();
104109
});
105110

106-
tape( 'the function computes `sin(πx)`', function test( t ) {
111+
tape( 'the function computes `sin(πx)` (decimal values)', function test( t ) {
107112
var expected;
108113
var x;
109114
var y;
@@ -119,3 +124,71 @@ tape( 'the function computes `sin(πx)`', function test( t ) {
119124
}
120125
t.end();
121126
});
127+
128+
tape( 'the function computes `sin(πx) (small negative values)`', function test( t ) {
129+
var expected;
130+
var x;
131+
var y;
132+
var i;
133+
134+
x = smallNegative.x;
135+
expected = smallNegative.expected;
136+
for ( i = 0; i < x.length; i++ ) {
137+
x[ i ] = f32( x[ i ] );
138+
expected[ i ] = f32( expected[ i ] );
139+
y = sinpif( x[ i ] );
140+
t.strictEqual( ulpdiff( y, expected[ i ] ) <= 1, true, 'returns expected value within 1 ulp' );
141+
}
142+
t.end();
143+
});
144+
145+
tape( 'the function computes `sin(πx) (small positive values)`', function test( t ) {
146+
var expected;
147+
var x;
148+
var y;
149+
var i;
150+
151+
x = smallPositive.x;
152+
expected = smallPositive.expected;
153+
for ( i = 0; i < x.length; i++ ) {
154+
x[ i ] = f32( x[ i ] );
155+
expected[ i ] = f32( expected[ i ] );
156+
y = sinpif( x[ i ] );
157+
t.strictEqual( ulpdiff( y, expected[ i ] ) <= 1, true, 'returns expected value within 1 ulp' );
158+
}
159+
t.end();
160+
});
161+
162+
tape( 'the function computes `sin(πx) (large negative values)`', function test( t ) {
163+
var expected;
164+
var x;
165+
var y;
166+
var i;
167+
168+
x = largeNegative.x;
169+
expected = largeNegative.expected;
170+
for ( i = 0; i < x.length; i++ ) {
171+
x[ i ] = f32( x[ i ] );
172+
expected[ i ] = f32( expected[ i ] );
173+
y = sinpif( x[ i ] );
174+
t.strictEqual( y, expected[ i ], 'returns expected value' );
175+
}
176+
t.end();
177+
});
178+
179+
tape( 'the function computes `sin(πx) (large positive values)`', function test( t ) {
180+
var expected;
181+
var x;
182+
var y;
183+
var i;
184+
185+
x = largePositive.x;
186+
expected = largePositive.expected;
187+
for ( i = 0; i < x.length; i++ ) {
188+
x[ i ] = f32( x[ i ] );
189+
expected[ i ] = f32( expected[ i ] );
190+
y = sinpif( x[ i ] );
191+
t.strictEqual( y, expected[ i ], 'returns expected value' );
192+
}
193+
t.end();
194+
});

lib/node_modules/@stdlib/math/base/special/sinpif/test/test.native.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var PINF = require( '@stdlib/constants/float32/pinf' );
2727
var NINF = require( '@stdlib/constants/float32/ninf' );
2828
var f32 = require( '@stdlib/number/float64/base/to-float32' );
29+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
2930
var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
3031
var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' );
3132
var isSameValue = require( '@stdlib/assert/is-same-value' );
@@ -44,6 +45,10 @@ var opts = {
4445

4546
var integers = require( './fixtures/julia/integers.json' );
4647
var decimals = require( './fixtures/julia/decimals.json' );
48+
var smallPositive = require( './fixtures/julia/small_positive.json' );
49+
var smallNegative = require( './fixtures/julia/small_negative.json' );
50+
var largePositive = require( './fixtures/julia/large_positive.json' );
51+
var largeNegative = require( './fixtures/julia/large_negative.json' );
4752

4853

4954
// TESTS //
@@ -112,7 +117,7 @@ tape( 'the function is odd', opts, function test( t ) {
112117
t.end();
113118
});
114119

115-
tape( 'the function computes `sin(πx)`', opts, function test( t ) {
120+
tape( 'the function computes `sin(πx)` (decimal values)', opts, function test( t ) {
116121
var expected;
117122
var x;
118123
var y;
@@ -128,3 +133,71 @@ tape( 'the function computes `sin(πx)`', opts, function test( t ) {
128133
}
129134
t.end();
130135
});
136+
137+
tape( 'the function computes `sin(πx) (small negative values)`', opts, function test( t ) {
138+
var expected;
139+
var x;
140+
var y;
141+
var i;
142+
143+
x = smallNegative.x;
144+
expected = smallNegative.expected;
145+
for ( i = 0; i < x.length; i++ ) {
146+
x[ i ] = f32( x[ i ] );
147+
expected[ i ] = f32( expected[ i ] );
148+
y = sinpif( x[ i ] );
149+
t.strictEqual( ulpdiff( y, expected[ i ] ) <= 1, true, 'returns expected value within 1 ulp' );
150+
}
151+
t.end();
152+
});
153+
154+
tape( 'the function computes `sin(πx) (small positive values)`', opts, function test( t ) {
155+
var expected;
156+
var x;
157+
var y;
158+
var i;
159+
160+
x = smallPositive.x;
161+
expected = smallPositive.expected;
162+
for ( i = 0; i < x.length; i++ ) {
163+
x[ i ] = f32( x[ i ] );
164+
expected[ i ] = f32( expected[ i ] );
165+
y = sinpif( x[ i ] );
166+
t.strictEqual( ulpdiff( y, expected[ i ] ) <= 1, true, 'returns expected value within 1 ulp' );
167+
}
168+
t.end();
169+
});
170+
171+
tape( 'the function computes `sin(πx) (large negative values)`', opts, function test( t ) {
172+
var expected;
173+
var x;
174+
var y;
175+
var i;
176+
177+
x = largeNegative.x;
178+
expected = largeNegative.expected;
179+
for ( i = 0; i < x.length; i++ ) {
180+
x[ i ] = f32( x[ i ] );
181+
expected[ i ] = f32( expected[ i ] );
182+
y = sinpif( x[ i ] );
183+
t.strictEqual( y, expected[ i ], 'returns expected value' );
184+
}
185+
t.end();
186+
});
187+
188+
tape( 'the function computes `sin(πx) (large positive values)`', opts, function test( t ) {
189+
var expected;
190+
var x;
191+
var y;
192+
var i;
193+
194+
x = largePositive.x;
195+
expected = largePositive.expected;
196+
for ( i = 0; i < x.length; i++ ) {
197+
x[ i ] = f32( x[ i ] );
198+
expected[ i ] = f32( expected[ i ] );
199+
y = sinpif( x[ i ] );
200+
t.strictEqual( y, expected[ i ], 'returns expected value' );
201+
}
202+
t.end();
203+
});

0 commit comments

Comments
 (0)