|
22 | 22 |
|
23 | 23 | var tape = require( 'tape' );
|
24 | 24 | var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
|
| 25 | +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; |
25 | 26 | var PINF = require( '@stdlib/constants/float32/pinf' );
|
26 | 27 | var NINF = require( '@stdlib/constants/float32/ninf' );
|
27 | 28 | var f32 = require( '@stdlib/number/float64/base/to-float32' );
|
@@ -194,3 +195,48 @@ tape( 'the function computes `cos(πx)` (large positive values)', function test(
|
194 | 195 | }
|
195 | 196 | t.end();
|
196 | 197 | });
|
| 198 | + |
| 199 | +tape( 'the function handles very small non-zero values', function test( t ) { |
| 200 | + var y; |
| 201 | + |
| 202 | + y = cospif( f32( 1e-6 ) ); |
| 203 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 204 | + |
| 205 | + y = cospif( f32( -1e-6 ) ); |
| 206 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 207 | + |
| 208 | + y = cospif( f32( 1e-8 ) ); |
| 209 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 210 | + |
| 211 | + t.end(); |
| 212 | +}); |
| 213 | + |
| 214 | +tape( 'the function handles large values with small fractional parts', function test( t ) { |
| 215 | + var y; |
| 216 | + |
| 217 | + y = cospif( f32( 100.1 ) ); |
| 218 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 219 | + |
| 220 | + y = cospif( f32( 1000.15 ) ); |
| 221 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 222 | + |
| 223 | + y = cospif( f32( 5000.2 ) ); |
| 224 | + t.strictEqual( isNumber( y ), true, 'returns expected value' ); |
| 225 | + |
| 226 | + t.end(); |
| 227 | +}); |
| 228 | + |
| 229 | +tape( 'the function returns `-1` for odd integers in [2^23, 2^24) range', function test( t ) { |
| 230 | + var y; |
| 231 | + |
| 232 | + y = cospif( f32( 8388609.0 ) ); // 2^23 + 1 |
| 233 | + t.strictEqual( y, f32( -1.0 ), 'returns expected value' ); |
| 234 | + |
| 235 | + y = cospif( f32( 10000001.0 ) ); |
| 236 | + t.strictEqual( y, f32( -1.0 ), 'returns expected value' ); |
| 237 | + |
| 238 | + y = cospif( f32( 16777215.0 ) ); // 2^24 - 1 (odd) |
| 239 | + t.strictEqual( y, f32( -1.0 ), 'returns expected value' ); |
| 240 | + |
| 241 | + t.end(); |
| 242 | +}); |
0 commit comments