20
20
21
21
// MODULES //
22
22
23
+ var resolve = require ( 'path' ) . resolve ;
23
24
var tape = require ( 'tape' ) ;
25
+ var tryRequire = require ( '@stdlib/utils/try-require' ) ;
24
26
var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
25
27
var abs = require ( '@stdlib/math/base/special/abs' ) ;
26
28
var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
27
29
var NINF = require ( '@stdlib/constants/float64/ninf' ) ;
28
30
var EPS = require ( '@stdlib/constants/float64/eps' ) ;
29
- var logpdf = require ( './../lib' ) ;
30
31
31
32
32
33
// FIXTURES //
@@ -36,15 +37,23 @@ var negativeMean = require( './fixtures/julia/negative_mean.json' );
36
37
var largeVariance = require ( './fixtures/julia/large_variance.json' ) ;
37
38
38
39
40
+ // VARIABLES //
41
+
42
+ var logpdf = tryRequire ( resolve ( __dirname , './../lib/native.js' ) ) ;
43
+ var opts = {
44
+ 'skip' : ( logpdf instanceof Error )
45
+ } ;
46
+
47
+
39
48
// TESTS //
40
49
41
- tape ( 'main export is a function' , function test ( t ) {
50
+ tape ( 'main export is a function' , opts , function test ( t ) {
42
51
t . ok ( true , __filename ) ;
43
52
t . strictEqual ( typeof logpdf , 'function' , 'main export is a function' ) ;
44
53
t . end ( ) ;
45
54
} ) ;
46
55
47
- tape ( 'if provided `NaN` for any parameter, the function returns `NaN`' , function test ( t ) {
56
+ tape ( 'if provided `NaN` for any parameter, the function returns `NaN`' , opts , function test ( t ) {
48
57
var y = logpdf ( NaN , 0.0 , 1.0 ) ;
49
58
t . equal ( isnan ( y ) , true , 'returns NaN' ) ;
50
59
y = logpdf ( 0.0 , NaN , 1.0 ) ;
@@ -54,19 +63,19 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', functio
54
63
t . end ( ) ;
55
64
} ) ;
56
65
57
- tape ( 'if provided `+infinity` for `x` and a finite `mu` and `s`, the function returns `-infinity`' , function test ( t ) {
66
+ tape ( 'if provided `+infinity` for `x` and a finite `mu` and `s`, the function returns `-infinity`' , opts , function test ( t ) {
58
67
var y = logpdf ( PINF , 0.0 , 1.0 ) ;
59
68
t . equal ( y , NINF , 'returns -infinity' ) ;
60
69
t . end ( ) ;
61
70
} ) ;
62
71
63
- tape ( 'if provided `-infinity` for `x` and a finite `mu` and `s`, the function returns `-infinity`' , function test ( t ) {
72
+ tape ( 'if provided `-infinity` for `x` and a finite `mu` and `s`, the function returns `-infinity`' , opts , function test ( t ) {
64
73
var y = logpdf ( NINF , 0.0 , 1.0 ) ;
65
74
t . equal ( y , NINF , 'returns -infinity' ) ;
66
75
t . end ( ) ;
67
76
} ) ;
68
77
69
- tape ( 'if provided a negative `s`, the function returns `NaN`' , function test ( t ) {
78
+ tape ( 'if provided a negative `s`, the function returns `NaN`' , opts , function test ( t ) {
70
79
var y ;
71
80
72
81
y = logpdf ( 2.0 , 2.0 , - 1.0 ) ;
@@ -90,7 +99,7 @@ tape( 'if provided a negative `s`, the function returns `NaN`', function test( t
90
99
t . end ( ) ;
91
100
} ) ;
92
101
93
- tape ( 'if provided `s` equal to `0`, the function evaluates a degenerate distribution centered at `mu`' , function test ( t ) {
102
+ tape ( 'if provided `s` equal to `0`, the function evaluates a degenerate distribution centered at `mu`' , opts , function test ( t ) {
94
103
var y ;
95
104
96
105
y = logpdf ( 2.0 , 2.0 , 0.0 ) ;
@@ -111,7 +120,7 @@ tape( 'if provided `s` equal to `0`, the function evaluates a degenerate distrib
111
120
t . end ( ) ;
112
121
} ) ;
113
122
114
- tape ( 'the function evaluates the logpdf for `x` given positive `mu`' , function test ( t ) {
123
+ tape ( 'the function evaluates the logpdf for `x` given positive `mu`' , opts , function test ( t ) {
115
124
var expected ;
116
125
var delta ;
117
126
var tol ;
@@ -140,7 +149,7 @@ tape( 'the function evaluates the logpdf for `x` given positive `mu`', function
140
149
t . end ( ) ;
141
150
} ) ;
142
151
143
- tape ( 'the function evaluates the logpdf for `x` given negative `mu`' , function test ( t ) {
152
+ tape ( 'the function evaluates the logpdf for `x` given negative `mu`' , opts , function test ( t ) {
144
153
var expected ;
145
154
var delta ;
146
155
var tol ;
@@ -169,7 +178,7 @@ tape( 'the function evaluates the logpdf for `x` given negative `mu`', function
169
178
t . end ( ) ;
170
179
} ) ;
171
180
172
- tape ( 'the function evaluates the logpdf for `x` given large variance ( = large `s` )' , function test ( t ) {
181
+ tape ( 'the function evaluates the logpdf for `x` given large variance ( = large `s` )' , opts , function test ( t ) {
173
182
var expected ;
174
183
var delta ;
175
184
var tol ;
0 commit comments