| 
1 | 1 | /**  | 
2 | 2 | * @license Apache-2.0  | 
3 | 3 | *  | 
4 |  | -* Copyright (c) 2018 The Stdlib Authors.  | 
 | 4 | +* Copyright (c) 2023 The Stdlib Authors.  | 
5 | 5 | *  | 
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License");  | 
7 | 7 | * you may not use this file except in compliance with the License.  | 
 | 
21 | 21 | // MODULES //  | 
22 | 22 | 
 
  | 
23 | 23 | var tape = require( 'tape' );  | 
24 |  | -var trunc = require( '@stdlib/math-base-special-trunc' );  | 
25 |  | -var randu = require( '@stdlib/random-base-randu' );  | 
26 |  | -var MIN_SAFE_INTEGER = require( '@stdlib/constants-float64-min-safe-integer' );  | 
27 |  | -var MAX_SAFE_INTEGER = require( '@stdlib/constants-float64-max-safe-integer' );  | 
28 |  | -var PINF = require( '@stdlib/constants-float64-pinf' );  | 
29 |  | -var NINF = require( '@stdlib/constants-float64-ninf' );  | 
30 |  | -var isSafeInteger = require( './../../dist' );  | 
 | 24 | +var main = require( './../../dist' );  | 
31 | 25 | 
 
  | 
32 | 26 | 
 
  | 
33 | 27 | // TESTS //  | 
34 | 28 | 
 
  | 
35 |  | -tape( 'main export is a function', function test( t ) {  | 
 | 29 | +tape( 'main export is defined', function test( t ) {  | 
36 | 30 | 	t.ok( true, __filename );  | 
37 |  | -	t.strictEqual( typeof isSafeInteger, 'function', 'main export is a function' );  | 
38 |  | -	t.end();  | 
39 |  | -});  | 
40 |  | - | 
41 |  | -tape( 'the function returns `true` if provided a safe integer', function test( t ) {  | 
42 |  | -	var i;  | 
43 |  | -	for ( i = -50; i < 51; i++ ) {  | 
44 |  | -		t.equal( isSafeInteger( i ), true, 'returns true when provided '+i );  | 
45 |  | -	}  | 
46 |  | -	t.end();  | 
47 |  | -});  | 
48 |  | - | 
49 |  | -tape( 'the function returns `false` if provided an integer greater than the max safe integer', function test( t ) {  | 
50 |  | -	var x;  | 
51 |  | -	var i;  | 
52 |  | -	for ( i = 1; i < 100; i++ ) {  | 
53 |  | -		x = MAX_SAFE_INTEGER + 1 + i;  | 
54 |  | -		t.equal( isSafeInteger( x ), false, 'returns false when provided '+x );  | 
55 |  | -	}  | 
56 |  | -	t.end();  | 
57 |  | -});  | 
58 |  | - | 
59 |  | -tape( 'the function returns `false` if provided an integer less than the min safe integer', function test( t ) {  | 
60 |  | -	var x;  | 
61 |  | -	var i;  | 
62 |  | -	for ( i = 0; i < 100; i++ ) {  | 
63 |  | -		x = MIN_SAFE_INTEGER - 1 - i;  | 
64 |  | -		t.equal( isSafeInteger( x ), false, 'returns false when provided '+x );  | 
65 |  | -	}  | 
66 |  | -	t.end();  | 
67 |  | -});  | 
68 |  | - | 
69 |  | -tape( 'the function returns `false` if not provided an integer', function test( t ) {  | 
70 |  | -	var v;  | 
71 |  | -	var i;  | 
72 |  | -	for ( i = 0; i < 100; i++ ) {  | 
73 |  | -		v = (randu()*100.0) - 50.0;  | 
74 |  | -		if ( trunc(v) !== v ) {  | 
75 |  | -			t.equal( isSafeInteger( v ), false, 'returns false when provided '+v );  | 
76 |  | -		}  | 
77 |  | -	}  | 
78 |  | -	t.end();  | 
79 |  | -});  | 
80 |  | - | 
81 |  | -tape( 'the function returns `true` if provided maximum safe integer', function test( t ) {  | 
82 |  | -	t.equal( isSafeInteger( MAX_SAFE_INTEGER ), true, 'returns true' );  | 
83 |  | -	t.end();  | 
84 |  | -});  | 
85 |  | - | 
86 |  | -tape( 'the function returns `true` if provided minimum safe integer', function test( t ) {  | 
87 |  | -	t.equal( isSafeInteger( MIN_SAFE_INTEGER ), true, 'returns true' );  | 
88 |  | -	t.end();  | 
89 |  | -});  | 
90 |  | - | 
91 |  | -tape( 'the function returns `false` if provided `NaN`', function test( t ) {  | 
92 |  | -	t.equal( isSafeInteger( NaN ), false, 'returns false' );  | 
93 |  | -	t.end();  | 
94 |  | -});  | 
95 |  | - | 
96 |  | -tape( 'the function returns `false` if provided `+infinity`', function test( t ) {  | 
97 |  | -	t.equal( isSafeInteger( PINF ), false, 'returns false' );  | 
98 |  | -	t.end();  | 
99 |  | -});  | 
100 |  | - | 
101 |  | -tape( 'the function returns `false` if provided `-infinity`', function test( t ) {  | 
102 |  | -	t.equal( isSafeInteger( NINF ), false, 'returns false' );  | 
 | 31 | +	t.strictEqual( main !== void 0, true, 'main export is defined' );  | 
103 | 32 | 	t.end();  | 
104 | 33 | });  | 
0 commit comments