21
21
// MODULES //
22
22
23
23
var tape = require ( 'tape' ) ;
24
- var gamma = require ( 'gamma' ) ; // eslint-disable-line stdlib/ require-file-extensions
24
+ var tryRequire = require ( '@stdlib/utils/try- require' ) ;
25
25
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
26
26
var incrspace = require ( '@stdlib/array/base/incrspace' ) ;
27
27
var abs = require ( '@stdlib/math/base/special/abs' ) ;
@@ -30,6 +30,14 @@ var PINF = require( '@stdlib/constants/float64/pinf' );
30
30
var NINF = require ( '@stdlib/constants/float64/ninf' ) ;
31
31
32
32
33
+ // VARIABLES //
34
+
35
+ var gamma = tryRequire ( 'gamma' ) ;
36
+ var opts = {
37
+ 'skip' : ( gamma instanceof Error )
38
+ } ;
39
+
40
+
33
41
// FIXTURES //
34
42
35
43
var data1 = require ( './../fixtures/r/data1.json' ) ;
@@ -40,13 +48,13 @@ var expected2 = require( './../fixtures/r/expected2.json' );
40
48
41
49
// TESTS //
42
50
43
- tape ( 'main export is a function' , function test ( t ) {
51
+ tape ( 'main export is a function' , opts , function test ( t ) {
44
52
t . ok ( true , __filename ) ;
45
53
t . strictEqual ( typeof gamma , 'function' , 'main export is a function' ) ;
46
54
t . end ( ) ;
47
55
} ) ;
48
56
49
- tape ( 'if provided a negative integer, the function returns `NaN`' , function test ( t ) {
57
+ tape ( 'if provided a negative integer, the function returns `NaN`' , opts , function test ( t ) {
50
58
var values = incrspace ( - 1.0 , - 1000.0 , - 1.0 ) ;
51
59
var v ;
52
60
var i ;
@@ -58,31 +66,31 @@ tape( 'if provided a negative integer, the function returns `NaN`', function tes
58
66
t . end ( ) ;
59
67
} ) ;
60
68
61
- tape ( 'if provided negative infinity, the function returns `NaN`' , function test ( t ) {
69
+ tape ( 'if provided negative infinity, the function returns `NaN`' , opts , function test ( t ) {
62
70
var v = gamma ( NINF ) ;
63
71
t . strictEqual ( isnan ( v ) , true , 'returns NaN when provided negative infinity' ) ;
64
72
t . end ( ) ;
65
73
} ) ;
66
74
67
- tape ( 'if provided `NaN`, the function returns `NaN`' , function test ( t ) {
75
+ tape ( 'if provided `NaN`, the function returns `NaN`' , opts , function test ( t ) {
68
76
var v = gamma ( NaN ) ;
69
77
t . strictEqual ( isnan ( v ) , true , 'returns NaN when provided a NaN' ) ;
70
78
t . end ( ) ;
71
79
} ) ;
72
80
73
- tape ( 'if provided `-0`, the function returns negative infinity' , function test ( t ) {
81
+ tape ( 'if provided `-0`, the function returns negative infinity' , opts , function test ( t ) {
74
82
var v = gamma ( - 0.0 ) ;
75
83
t . strictEqual ( v , NINF , 'returns -infinity' ) ;
76
84
t . end ( ) ;
77
85
} ) ;
78
86
79
- tape ( 'if provided `+0`, the function returns positive infinity' , function test ( t ) {
87
+ tape ( 'if provided `+0`, the function returns positive infinity' , opts , function test ( t ) {
80
88
var v = gamma ( 0.0 ) ;
81
89
t . strictEqual ( v , PINF , 'returns +infinity' ) ;
82
90
t . end ( ) ;
83
91
} ) ;
84
92
85
- tape ( 'if `x > 171.6144...`, the function returns positive infinity' , function test ( t ) {
93
+ tape ( 'if `x > 171.6144...`, the function returns positive infinity' , opts , function test ( t ) {
86
94
var values = incrspace ( 172.0 , 1000.0 , 10.1234 ) ;
87
95
var v ;
88
96
var i ;
@@ -94,7 +102,7 @@ tape( 'if `x > 171.6144...`, the function returns positive infinity', function t
94
102
t . end ( ) ;
95
103
} ) ;
96
104
97
- tape ( 'if `x < -170.56749...`, the function returns positive infinity' , function test ( t ) {
105
+ tape ( 'if `x < -170.56749...`, the function returns positive infinity' , opts , function test ( t ) {
98
106
var values = incrspace ( - 170.57 , - 1000.0 , - 10.1234 ) ;
99
107
var v ;
100
108
var i ;
@@ -106,7 +114,7 @@ tape( 'if `x < -170.56749...`, the function returns positive infinity', function
106
114
t . end ( ) ;
107
115
} ) ;
108
116
109
- tape ( 'the function evaluates the gamma function (positive integers)' , function test ( t ) {
117
+ tape ( 'the function evaluates the gamma function (positive integers)' , opts , function test ( t ) {
110
118
var delta ;
111
119
var tol ;
112
120
var v ;
@@ -121,7 +129,7 @@ tape( 'the function evaluates the gamma function (positive integers)', function
121
129
t . end ( ) ;
122
130
} ) ;
123
131
124
- tape ( 'the function evaluates the gamma function (decimal values)' , function test ( t ) {
132
+ tape ( 'the function evaluates the gamma function (decimal values)' , opts , function test ( t ) {
125
133
var delta ;
126
134
var tol ;
127
135
var v ;
@@ -136,7 +144,7 @@ tape( 'the function evaluates the gamma function (decimal values)', function tes
136
144
t . end ( ) ;
137
145
} ) ;
138
146
139
- tape ( 'if provided a positive integer, the function returns the factorial of (n-1)' , function test ( t ) {
147
+ tape ( 'if provided a positive integer, the function returns the factorial of (n-1)' , opts , function test ( t ) {
140
148
t . strictEqual ( gamma ( 4.0 ) , 6.0 , 'returns 6' ) ;
141
149
t . strictEqual ( gamma ( 5.0 ) , 24.0 , 'returns 24' ) ;
142
150
t . strictEqual ( gamma ( 6.0 ) , 120.0 , 'returns 120' ) ;
0 commit comments