20
20
21
21
// MODULES //
22
22
23
+ var resolve = require ( 'path' ) . resolve ;
23
24
var tape = require ( 'tape' ) ;
24
25
var PI = require ( '@stdlib/constants/float64/pi' ) ;
25
26
var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
26
27
var NINF = require ( '@stdlib/constants/float64/ninf' ) ;
27
28
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
28
29
var isNegativeZero = require ( '@stdlib/math/base/assert/is-negative-zero' ) ;
29
30
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
+ } ;
31
40
32
41
33
42
// TESTS //
34
43
35
- tape ( 'main export is a function' , function test ( t ) {
44
+ tape ( 'main export is a function' , opts , function test ( t ) {
36
45
t . ok ( true , __filename ) ;
37
46
t . strictEqual ( typeof ceilsd , 'function' , 'main export is a function' ) ;
38
47
t . end ( ) ;
39
48
} ) ;
40
49
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 ) {
42
51
var v ;
43
52
44
53
v = ceilsd ( NaN , 2 , 10 ) ;
45
- t . strictEqual ( isnan ( v ) , true , 'returns NaN ' ) ;
54
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value ' ) ;
46
55
t . end ( ) ;
47
56
} ) ;
48
57
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 ) {
50
59
var v ;
51
60
52
61
v = ceilsd ( PI , 0 , 10 ) ;
53
- t . strictEqual ( isnan ( v ) , true , 'returns NaN ' ) ;
62
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value ' ) ;
54
63
55
64
v = ceilsd ( PI , - 1 , 10 ) ;
56
- t . strictEqual ( isnan ( v ) , true , 'returns NaN ' ) ;
65
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value ' ) ;
57
66
58
67
t . end ( ) ;
59
68
} ) ;
60
69
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 ) {
62
71
var v ;
63
72
64
73
v = ceilsd ( PI , 2 , 0 ) ;
65
- t . strictEqual ( isnan ( v ) , true , 'returns NaN ' ) ;
74
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value ' ) ;
66
75
67
76
v = ceilsd ( PI , 2 , - 1 ) ;
68
- t . strictEqual ( isnan ( v ) , true , 'returns NaN ' ) ;
77
+ t . strictEqual ( isnan ( v ) , true , 'returns expected value ' ) ;
69
78
70
79
t . end ( ) ;
71
80
} ) ;
72
81
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 ) {
74
83
var v = ceilsd ( PINF , 5 , 10 ) ;
75
84
t . strictEqual ( v , PINF , 'returns +infinity' ) ;
76
85
t . end ( ) ;
77
86
} ) ;
78
87
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 ) {
80
89
var v = ceilsd ( NINF , 3 , 10 ) ;
81
90
t . strictEqual ( v , NINF , 'returns -infinity' ) ;
82
91
t . end ( ) ;
83
92
} ) ;
84
93
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 ) {
86
95
var v ;
87
96
88
97
v = ceilsd ( - 0.0 , 1 , 10 ) ;
@@ -94,7 +103,7 @@ tape( 'the function returns `-0` if provided `-0`', function test( t ) {
94
103
t . end ( ) ;
95
104
} ) ;
96
105
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 ) {
98
107
var v ;
99
108
100
109
v = ceilsd ( 0.0 , 1 , 10 ) ;
@@ -106,7 +115,7 @@ tape( 'the function returns `+0` if provided `+0`', function test( t ) {
106
115
t . end ( ) ;
107
116
} ) ;
108
117
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 ) {
110
119
t . strictEqual ( ceilsd ( PI , 1 , 10 ) , 4.0 , 'returns expected value' ) ;
111
120
t . strictEqual ( ceilsd ( - PI , 1 , 10 ) , - 3.0 , 'returns expected value' ) ;
112
121
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
123
132
t . end ( ) ;
124
133
} ) ;
125
134
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 ) {
127
136
t . strictEqual ( ceilsd ( 0.0313 , 1 , 2 ) , 0.0625 , 'returns expected value' ) ;
128
137
t . strictEqual ( ceilsd ( 0.0313 , 2 , 2 ) , 0.046875 , 'returns expected value' ) ;
129
138
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
141
150
t . end ( ) ;
142
151
} ) ;
143
152
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 ) {
145
154
t . strictEqual ( ceilsd ( 0.0313 , 1 , 16 ) , 0.03515625 , 'returns expected value' ) ;
146
155
t . strictEqual ( ceilsd ( 0.0313 , 5 , 16 ) , 0.03130000829696655 , 'returns expected value' ) ;
147
156
t . end ( ) ;
148
157
} ) ;
149
158
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 ) {
151
160
var x ;
152
161
var v ;
153
162
0 commit comments