Skip to content

Commit 9ca7034

Browse files
committed
test: add tests for IEEE 754-2019 compliance
--- 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 633dc6b commit 9ca7034

File tree

5 files changed

+82
-16
lines changed

5 files changed

+82
-16
lines changed

lib/node_modules/@stdlib/math/base/special/cscd/test/fixtures/julia/negative.json

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

lib/node_modules/@stdlib/math/base/special/cscd/test/fixtures/julia/positive.json

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ file = @__FILE__;
6262
dir = dirname( file );
6363

6464
# Generate fixture data for negative values:
65-
x = range( -360.0, stop = 0.0, length = 1000 );
65+
x = range( -360.0, stop = 0.1, length = 1000 );
6666
gen( x, "negative.json" );
6767

6868
# Generate fixture data for positive values:
69-
x = range( 0.0, stop = 360.0, length = 1000 );
69+
x = range( 0.1, stop = 360.0, length = 1000 );
7070
gen( x, "positive.json" );

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

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var EPS = require( '@stdlib/constants/float64/eps' );
2626
var PINF = require( '@stdlib/constants/float64/pinf' );
27+
var NINF = require( '@stdlib/constants/float64/ninf' );
2728
var abs = require( '@stdlib/math/base/special/abs' );
2829
var cscd = require( './../lib' );
2930

@@ -44,7 +45,39 @@ tape( 'main export is a function', function test( t ) {
4445

4546
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
4647
var v = cscd( NaN );
47-
t.equal( isnan( v ), true, 'returns expected value' );
48+
t.strictEqual( isnan( v ), true, 'returns expected value' );
49+
t.end();
50+
});
51+
52+
tape( 'if provided a positive multiple of `180.0`, the function returns `+infinity`', function test( t ) {
53+
var v = cscd( 180.0 );
54+
t.strictEqual( PINF, v, 'returns expected value' );
55+
56+
v = cscd( 360.0 );
57+
t.strictEqual( PINF, v, 'returns expected value' );
58+
59+
t.end();
60+
});
61+
62+
tape( 'if provided a negative multiple of `180.0`, the function returns `-infinity`', function test( t ) {
63+
var v = cscd( -180.0 );
64+
t.strictEqual( NINF, v, 'returns expected value' );
65+
66+
v = cscd( -360.0 );
67+
t.strictEqual( NINF, v, 'returns expected value' );
68+
69+
t.end();
70+
});
71+
72+
tape( 'the function returns `-0` if provided `-infinity`', function test( t ) {
73+
var v = cscd( -0.0 );
74+
t.strictEqual( NINF, v, 'returns expected value' );
75+
t.end();
76+
});
77+
78+
tape( 'the function returns `+0` if provided `+infinity`', function test( t ) {
79+
var v = cscd( 0.0 );
80+
t.strictEqual( PINF, v, 'returns expected value' );
4881
t.end();
4982
});
5083

@@ -62,14 +95,14 @@ tape( 'the function computes the cosecant in degrees (negative values)', functio
6295
for ( i = 0; i < x.length; i++ ) {
6396
y = cscd( x[i] );
6497
if ( expected[ i ] === null ) {
65-
t.equal( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
98+
t.strictEqual( y, NINF, 'x: '+x[i]+'. E: '+expected[i] );
6699
continue;
67100
}
68101
if ( y === expected[ i ] ) {
69-
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
102+
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
70103
} else {
71104
delta = abs( y - expected[i] );
72-
tol = 1.3 * EPS * abs( expected[i] );
105+
tol = 1.4 * EPS * abs( expected[i] );
73106
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
74107
}
75108
}
@@ -90,14 +123,14 @@ tape( 'the function computes the cosecant in degrees (positive values)', functio
90123
for ( i = 0; i < x.length; i++ ) {
91124
y = cscd( x[i] );
92125
if ( expected[ i ] === null ) {
93-
t.equal( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
126+
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
94127
continue;
95128
}
96129
if ( y === expected[ i ] ) {
97-
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
130+
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
98131
} else {
99132
delta = abs( y - expected[i] );
100-
tol = 1.3 * EPS * abs( expected[i] );
133+
tol = 1.4 * EPS * abs( expected[i] );
101134
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
102135
}
103136
}

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

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var tape = require( 'tape' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var PINF = require( '@stdlib/constants/float64/pinf' );
28+
var NINF = require( '@stdlib/constants/float64/ninf' );
2829
var abs = require( '@stdlib/math/base/special/abs' );
2930
var tryRequire = require( '@stdlib/utils/try-require' );
3031

@@ -53,7 +54,39 @@ tape( 'main export is a function', opts, function test( t ) {
5354

5455
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
5556
var v = cscd( NaN );
56-
t.equal( isnan( v ), true, 'returns expected value' );
57+
t.strictEqual( isnan( v ), true, 'returns expected value' );
58+
t.end();
59+
});
60+
61+
tape( 'if provided a positive multiple of `180.0`, the function returns `+infinity`', opts, function test( t ) {
62+
var v = cscd( 180.0 );
63+
t.strictEqual( PINF, v, 'returns expected value' );
64+
65+
v = cscd( 360.0 );
66+
t.strictEqual( PINF, v, 'returns expected value' );
67+
68+
t.end();
69+
});
70+
71+
tape( 'if provided a negative multiple of `180.0`, the function returns `-infinity`', opts, function test( t ) {
72+
var v = cscd( -180.0 );
73+
t.strictEqual( NINF, v, 'returns expected value' );
74+
75+
v = cscd( -360.0 );
76+
t.strictEqual( NINF, v, 'returns expected value' );
77+
78+
t.end();
79+
});
80+
81+
tape( 'the function returns `-0` if provided `-infinity`', opts, function test( t ) {
82+
var v = cscd( -0.0 );
83+
t.strictEqual( NINF, v, 'returns expected value' );
84+
t.end();
85+
});
86+
87+
tape( 'the function returns `+0` if provided `+infinity`', opts, function test( t ) {
88+
var v = cscd( 0.0 );
89+
t.strictEqual( PINF, v, 'returns expected value' );
5790
t.end();
5891
});
5992

@@ -71,11 +104,11 @@ tape( 'the function computes the cosecant in degrees (negative values)', opts, f
71104
for ( i = 0; i < x.length; i++ ) {
72105
y = cscd( x[i] );
73106
if ( expected[ i ] === null ) {
74-
t.equal( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
107+
t.strictEqual( y, NINF, 'x: '+x[i]+'. E: '+expected[i] );
75108
continue;
76109
}
77110
if ( y === expected[ i ] ) {
78-
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
111+
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
79112
} else {
80113
delta = abs( y - expected[i] );
81114
tol = 1.4 * EPS * abs( expected[i] );
@@ -99,11 +132,11 @@ tape( 'the function computes the cosecant in degrees (positive values)', opts, f
99132
for ( i = 0; i < x.length; i++ ) {
100133
y = cscd( x[i] );
101134
if ( expected[ i ] === null ) {
102-
t.equal( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
135+
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
103136
continue;
104137
}
105138
if ( y === expected[ i ] ) {
106-
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
139+
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
107140
} else {
108141
delta = abs( y - expected[i] );
109142
tol = 1.4 * EPS * abs( expected[i] );

0 commit comments

Comments
 (0)