Skip to content

Commit b65c4fc

Browse files
committed
test: ensure no errors when gamma is not available
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 474fc56 commit b65c4fc

File tree

1 file changed

+20
-12
lines changed
  • lib/node_modules/@stdlib/math/base/special/gamma/test/other

1 file changed

+20
-12
lines changed

lib/node_modules/@stdlib/math/base/special/gamma/test/other/xtest.gamma.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var gamma = require( 'gamma' ); // eslint-disable-line stdlib/require-file-extensions
24+
var tryRequire = require( '@stdlib/utils/try-require' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var incrspace = require( '@stdlib/array/base/incrspace' );
2727
var abs = require( '@stdlib/math/base/special/abs' );
@@ -30,6 +30,14 @@ var PINF = require( '@stdlib/constants/float64/pinf' );
3030
var NINF = require( '@stdlib/constants/float64/ninf' );
3131

3232

33+
// VARIABLES //
34+
35+
var gamma = tryRequire( 'gamma' );
36+
var opts = {
37+
'skip': ( gamma instanceof Error )
38+
};
39+
40+
3341
// FIXTURES //
3442

3543
var data1 = require( './../fixtures/r/data1.json' );
@@ -40,13 +48,13 @@ var expected2 = require( './../fixtures/r/expected2.json' );
4048

4149
// TESTS //
4250

43-
tape( 'main export is a function', function test( t ) {
51+
tape( 'main export is a function', opts, function test( t ) {
4452
t.ok( true, __filename );
4553
t.strictEqual( typeof gamma, 'function', 'main export is a function' );
4654
t.end();
4755
});
4856

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 ) {
5058
var values = incrspace( -1.0, -1000.0, -1.0 );
5159
var v;
5260
var i;
@@ -58,31 +66,31 @@ tape( 'if provided a negative integer, the function returns `NaN`', function tes
5866
t.end();
5967
});
6068

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 ) {
6270
var v = gamma( NINF );
6371
t.strictEqual( isnan( v ), true, 'returns NaN when provided negative infinity' );
6472
t.end();
6573
});
6674

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 ) {
6876
var v = gamma( NaN );
6977
t.strictEqual( isnan( v ), true, 'returns NaN when provided a NaN' );
7078
t.end();
7179
});
7280

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 ) {
7482
var v = gamma( -0.0 );
7583
t.strictEqual( v, NINF, 'returns -infinity' );
7684
t.end();
7785
});
7886

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 ) {
8088
var v = gamma( 0.0 );
8189
t.strictEqual( v, PINF, 'returns +infinity' );
8290
t.end();
8391
});
8492

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 ) {
8694
var values = incrspace( 172.0, 1000.0, 10.1234 );
8795
var v;
8896
var i;
@@ -94,7 +102,7 @@ tape( 'if `x > 171.6144...`, the function returns positive infinity', function t
94102
t.end();
95103
});
96104

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 ) {
98106
var values = incrspace( -170.57, -1000.0, -10.1234 );
99107
var v;
100108
var i;
@@ -106,7 +114,7 @@ tape( 'if `x < -170.56749...`, the function returns positive infinity', function
106114
t.end();
107115
});
108116

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 ) {
110118
var delta;
111119
var tol;
112120
var v;
@@ -121,7 +129,7 @@ tape( 'the function evaluates the gamma function (positive integers)', function
121129
t.end();
122130
});
123131

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 ) {
125133
var delta;
126134
var tol;
127135
var v;
@@ -136,7 +144,7 @@ tape( 'the function evaluates the gamma function (decimal values)', function tes
136144
t.end();
137145
});
138146

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 ) {
140148
t.strictEqual( gamma( 4.0 ), 6.0, 'returns 6' );
141149
t.strictEqual( gamma( 5.0 ), 24.0, 'returns 24' );
142150
t.strictEqual( gamma( 6.0 ), 120.0, 'returns 120' );

0 commit comments

Comments
 (0)