Skip to content

Commit d8437b8

Browse files
test: add tests for IEEE 754-2019 compliance
PR-URL: #6563 Ref: #365 Reviewed-by: Athan Reines <[email protected]>
1 parent f7db171 commit d8437b8

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,17 @@ tape( 'the function returns `-135.0` if provided `x = y = -infinity`', function
113113
t.end();
114114
});
115115

116-
tape( 'the function returns `0.0` when `x = +infinity`', function test( t ) {
117-
t.equal( atan2d( -2.0, PINF ), 0.0, 'returns expected value' );
118-
t.equal( atan2d( 0.0, PINF ), 0.0, 'returns expected value' );
119-
t.equal( atan2d( 2.0, PINF ), 0.0, 'returns expected value' );
116+
tape( 'the function returns `0.0` when `y > 0` and `x = +infinity`', function test( t ) {
117+
t.equal( isPositiveZero( atan2d( 1.0, PINF ) ), true, 'returns expected value' );
118+
t.equal( isPositiveZero( atan2d( 2.0, PINF ) ), true, 'returns expected value' );
119+
t.equal( isPositiveZero( atan2d( 3.0, PINF ) ), true, 'returns expected value' );
120+
t.end();
121+
});
122+
123+
tape( 'the function returns `-0.0` when `y < 0` and `x = +infinity`', function test( t ) {
124+
t.equal( isNegativeZero( atan2d( -1.0, PINF ) ), true, 'returns expected value' );
125+
t.equal( isNegativeZero( atan2d( -2.0, PINF ) ), true, 'returns expected value' );
126+
t.equal( isNegativeZero( atan2d( -3.0, PINF ) ), true, 'returns expected value' );
120127
t.end();
121128
});
122129

@@ -155,13 +162,27 @@ tape( 'the function returns `90.0` if provided a positive `y` and `x=0`', functi
155162
t.end();
156163
});
157164

158-
tape( 'the function returns `90.0` if provided a negative `y` and `x=0`', function test( t ) {
165+
tape( 'the function returns `90.0` if provided a positive `y` and `x=-0`', function test( t ) {
166+
t.equal( atan2d( 2.0, -0.0 ), 90.0, 'returns expected value' );
167+
t.equal( atan2d( 1.0, -0.0 ), 90.0, 'returns expected value' );
168+
t.equal( atan2d( 0.5, -0.0 ), 90.0, 'returns expected value' );
169+
t.end();
170+
});
171+
172+
tape( 'the function returns `-90.0` if provided a negative `y` and `x=0`', function test( t ) {
159173
t.equal( atan2d( -2.0, 0.0 ), -90.0, 'returns expected value' );
160174
t.equal( atan2d( -1.0, 0.0 ), -90.0, 'returns expected value' );
161175
t.equal( atan2d( -0.5, 0.0 ), -90.0, 'returns expected value' );
162176
t.end();
163177
});
164178

179+
tape( 'the function returns `-90.0` if provided a negative `y` and `x=-0`', function test( t ) {
180+
t.equal( atan2d( -2.0, -0.0 ), -90.0, 'returns expected value' );
181+
t.equal( atan2d( -1.0, -0.0 ), -90.0, 'returns expected value' );
182+
t.equal( atan2d( -0.5, -0.0 ), -90.0, 'returns expected value' );
183+
t.end();
184+
});
185+
165186
tape( 'the function evaluates the `atan2d` function (when x and y are positive)', function test( t ) {
166187
var expected;
167188
var actual;

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,17 @@ tape( 'the function returns `-135.0` if provided `x = y = -infinity`', opts, fun
122122
t.end();
123123
});
124124

125-
tape( 'the function returns `0.0` when `x = +infinity`', opts, function test( t ) {
126-
t.equal( atan2d( -2.0, PINF ), 0.0, 'returns expected value' );
127-
t.equal( atan2d( 0.0, PINF ), 0.0, 'returns expected value' );
128-
t.equal( atan2d( 2.0, PINF ), 0.0, 'returns expected value' );
125+
tape( 'the function returns `0.0` when `y > 0` and `x = +infinity`', opts, function test( t ) {
126+
t.equal( isPositiveZero( atan2d( 1.0, PINF ) ), true, 'returns expected value' );
127+
t.equal( isPositiveZero( atan2d( 2.0, PINF ) ), true, 'returns expected value' );
128+
t.equal( isPositiveZero( atan2d( 3.0, PINF ) ), true, 'returns expected value' );
129+
t.end();
130+
});
131+
132+
tape( 'the function returns `-0.0` when `y < 0` and `x = +infinity`', opts, function test( t ) {
133+
t.equal( isNegativeZero( atan2d( -1.0, PINF ) ), true, 'returns expected value' );
134+
t.equal( isNegativeZero( atan2d( -2.0, PINF ) ), true, 'returns expected value' );
135+
t.equal( isNegativeZero( atan2d( -3.0, PINF ) ), true, 'returns expected value' );
129136
t.end();
130137
});
131138

@@ -164,13 +171,27 @@ tape( 'the function returns `90.0` if provided a positive `y` and `x=0`', opts,
164171
t.end();
165172
});
166173

167-
tape( 'the function returns `90.0` if provided a negative `y` and `x=0`', opts, function test( t ) {
174+
tape( 'the function returns `90.0` if provided a positive `y` and `x=-0`', opts, function test( t ) {
175+
t.equal( atan2d( 2.0, -0.0 ), 90.0, 'returns expected value' );
176+
t.equal( atan2d( 1.0, -0.0 ), 90.0, 'returns expected value' );
177+
t.equal( atan2d( 0.5, -0.0 ), 90.0, 'returns expected value' );
178+
t.end();
179+
});
180+
181+
tape( 'the function returns `-90.0` if provided a negative `y` and `x=0`', opts, function test( t ) {
168182
t.equal( atan2d( -2.0, 0.0 ), -90.0, 'returns expected value' );
169183
t.equal( atan2d( -1.0, 0.0 ), -90.0, 'returns expected value' );
170184
t.equal( atan2d( -0.5, 0.0 ), -90.0, 'returns expected value' );
171185
t.end();
172186
});
173187

188+
tape( 'the function returns `-90.0` if provided a negative `y` and `x=-0`', opts, function test( t ) {
189+
t.equal( atan2d( -2.0, -0.0 ), -90.0, 'returns expected value' );
190+
t.equal( atan2d( -1.0, -0.0 ), -90.0, 'returns expected value' );
191+
t.equal( atan2d( -0.5, -0.0 ), -90.0, 'returns expected value' );
192+
t.end();
193+
});
194+
174195
tape( 'the function evaluates the `atan2d` function (when x and y are positive)', opts, function test( t ) {
175196
var expected;
176197
var actual;

0 commit comments

Comments
 (0)