Skip to content

Commit 28d7e8e

Browse files
committed
test: fix tests for native implementation
PR-URL: stdlib-js#2641 Ref: stdlib-js#2631 Ref: stdlib-js@854b793 Reviewed-by: Athan Reines <[email protected]>
1 parent 9bd264a commit 28d7e8e

File tree

4 files changed

+31
-36
lines changed

4 files changed

+31
-36
lines changed

lib/node_modules/@stdlib/math/base/special/ceilsd/docs/repl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Number of significant figures. Must be greater than 0.
1313

1414
b: integer
15-
Base. Must be greater than 0. Default: 10.
15+
Base. Must be greater than 0.
1616

1717
Returns
1818
-------

lib/node_modules/@stdlib/math/base/special/ceilsd/docs/types/test.ts

-14
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ import ceilsd = require( './index' );
2828

2929
// The compiler throws an error if the function is provided values other than numbers...
3030
{
31-
ceilsd( true, 3 ); // $ExpectError
32-
ceilsd( false, 2 ); // $ExpectError
33-
ceilsd( '5', 1 ); // $ExpectError
34-
ceilsd( [], 1 ); // $ExpectError
35-
ceilsd( {}, 2 ); // $ExpectError
36-
ceilsd( ( x: number ): number => x, 2 ); // $ExpectError
37-
38-
ceilsd( 9, true ); // $ExpectError
39-
ceilsd( 9, false ); // $ExpectError
40-
ceilsd( 5, '5' ); // $ExpectError
41-
ceilsd( 8, [] ); // $ExpectError
42-
ceilsd( 9, {} ); // $ExpectError
43-
ceilsd( 8, ( x: number ): number => x ); // $ExpectError
44-
4531
ceilsd( true, 3, 2 ); // $ExpectError
4632
ceilsd( false, 2, 2 ); // $ExpectError
4733
ceilsd( '5', 1, 2 ); // $ExpectError

lib/node_modules/@stdlib/math/base/special/ceilsd/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ double stdlib_base_ceilsd( const double x, const int32_t n, const int32_t b ) {
5656
} else if ( b == 2 ) {
5757
exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) );
5858
} else {
59-
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( b );
59+
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( (double)b );
6060
}
61-
exp = stdlib_base_floor( exp - n + 1.0 );
62-
s = stdlib_base_pow( b, stdlib_base_abs( exp ) );
61+
exp = stdlib_base_floor( exp - (double)n + 1.0 );
62+
s = stdlib_base_pow( (double)b, stdlib_base_abs( exp ) );
6363

6464
// Check for overflow:
6565
if ( stdlib_base_is_infinite( s ) ) {

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

+27-18
Original file line numberDiff line numberDiff line change
@@ -20,69 +20,78 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( 'path' ).resolve;
2324
var tape = require( 'tape' );
2425
var PI = require( '@stdlib/constants/float64/pi' );
2526
var PINF = require( '@stdlib/constants/float64/pinf' );
2627
var NINF = require( '@stdlib/constants/float64/ninf' );
2728
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2829
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
2930
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
30-
var ceilsd = require( './../lib' );
31+
var tryRequire = require( '@stdlib/utils/try-require' );
32+
33+
34+
// VARIABLES //
35+
36+
var ceilsd = tryRequire( resolve( __dirname, './../lib/native.js' ) );
37+
var opts = {
38+
'skip': ( ceilsd instanceof Error )
39+
};
3140

3241

3342
// TESTS //
3443

35-
tape( 'main export is a function', function test( t ) {
44+
tape( 'main export is a function', opts, function test( t ) {
3645
t.ok( true, __filename );
3746
t.strictEqual( typeof ceilsd, 'function', 'main export is a function' );
3847
t.end();
3948
});
4049

41-
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
50+
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
4251
var v;
4352

4453
v = ceilsd( NaN, 2, 10 );
45-
t.strictEqual( isnan( v ), true, 'returns NaN' );
54+
t.strictEqual( isnan( v ), true, 'returns expected value' );
4655
t.end();
4756
});
4857

49-
tape( 'the function returns `NaN` if provided `n < 1`', function test( t ) {
58+
tape( 'the function returns `NaN` if provided `n < 1`', opts, function test( t ) {
5059
var v;
5160

5261
v = ceilsd( PI, 0, 10 );
53-
t.strictEqual( isnan( v ), true, 'returns NaN' );
62+
t.strictEqual( isnan( v ), true, 'returns expected value' );
5463

5564
v = ceilsd( PI, -1, 10 );
56-
t.strictEqual( isnan( v ), true, 'returns NaN' );
65+
t.strictEqual( isnan( v ), true, 'returns expected value' );
5766

5867
t.end();
5968
});
6069

61-
tape( 'the function returns `NaN` if provided `b <= 0`', function test( t ) {
70+
tape( 'the function returns `NaN` if provided `b <= 0`', opts, function test( t ) {
6271
var v;
6372

6473
v = ceilsd( PI, 2, 0 );
65-
t.strictEqual( isnan( v ), true, 'returns NaN' );
74+
t.strictEqual( isnan( v ), true, 'returns expected value' );
6675

6776
v = ceilsd( PI, 2, -1 );
68-
t.strictEqual( isnan( v ), true, 'returns NaN' );
77+
t.strictEqual( isnan( v ), true, 'returns expected value' );
6978

7079
t.end();
7180
});
7281

73-
tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) {
82+
tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) {
7483
var v = ceilsd( PINF, 5, 10 );
7584
t.strictEqual( v, PINF, 'returns +infinity' );
7685
t.end();
7786
});
7887

79-
tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) {
88+
tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) {
8089
var v = ceilsd( NINF, 3, 10 );
8190
t.strictEqual( v, NINF, 'returns -infinity' );
8291
t.end();
8392
});
8493

85-
tape( 'the function returns `-0` if provided `-0`', function test( t ) {
94+
tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) {
8695
var v;
8796

8897
v = ceilsd( -0.0, 1, 10 );
@@ -94,7 +103,7 @@ tape( 'the function returns `-0` if provided `-0`', function test( t ) {
94103
t.end();
95104
});
96105

97-
tape( 'the function returns `+0` if provided `+0`', function test( t ) {
106+
tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) {
98107
var v;
99108

100109
v = ceilsd( 0.0, 1, 10 );
@@ -106,7 +115,7 @@ tape( 'the function returns `+0` if provided `+0`', function test( t ) {
106115
t.end();
107116
});
108117

109-
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', function test( t ) {
118+
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', opts, function test( t ) {
110119
t.strictEqual( ceilsd( PI, 1, 10 ), 4.0, 'returns expected value' );
111120
t.strictEqual( ceilsd( -PI, 1, 10 ), -3.0, 'returns expected value' );
112121
t.strictEqual( ceilsd( PI, 2, 10 ), 3.2, 'returns expected value' );
@@ -123,7 +132,7 @@ tape( 'the function supports rounding a numeric value with a specified number of
123132
t.end();
124133
});
125134

126-
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', function test( t ) {
135+
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', opts, function test( t ) {
127136
t.strictEqual( ceilsd( 0.0313, 1, 2 ), 0.0625, 'returns expected value' );
128137
t.strictEqual( ceilsd( 0.0313, 2, 2 ), 0.046875, 'returns expected value' );
129138
t.strictEqual( ceilsd( 0.0313, 3, 2 ), 0.0390625, 'returns expected value' );
@@ -141,13 +150,13 @@ tape( 'the function supports rounding a numeric value with a specified number of
141150
t.end();
142151
});
143152

144-
tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', function test( t ) {
153+
tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', opts, function test( t ) {
145154
t.strictEqual( ceilsd( 0.0313, 1, 16 ), 0.03515625, 'returns expected value' );
146155
t.strictEqual( ceilsd( 0.0313, 5, 16 ), 0.03130000829696655, 'returns expected value' );
147156
t.end();
148157
});
149158

150-
tape( 'if the function encounters overflow, the function returns the input value', function test( t ) {
159+
tape( 'if the function encounters overflow, the function returns the input value', opts, function test( t ) {
151160
var x;
152161
var v;
153162

0 commit comments

Comments
 (0)