2020
2121// MODULES //
2222
23+ var resolve = require ( 'path' ) . resolve ;
2324var tape = require ( 'tape' ) ;
25+ var tryRequire = require ( '@stdlib/utils/try-require' ) ;
2426var isnan = require ( '@stdlib/math/base/assert/is-nan' ) ;
2527var abs = require ( '@stdlib/math/base/special/abs' ) ;
2628var PINF = require ( '@stdlib/constants/float64/pinf' ) ;
2729var NINF = require ( '@stdlib/constants/float64/ninf' ) ;
2830var EPS = require ( '@stdlib/constants/float64/eps' ) ;
29- var logpdf = require ( './../lib' ) ;
3031
3132
3233// FIXTURES //
@@ -36,15 +37,23 @@ var negativeMean = require( './fixtures/julia/negative_mean.json' );
3637var largeVariance = require ( './fixtures/julia/large_variance.json' ) ;
3738
3839
40+ // VARIABLES //
41+
42+ var logpdf = tryRequire ( resolve ( __dirname , './../lib/native.js' ) ) ;
43+ var opts = {
44+ 'skip' : ( logpdf instanceof Error )
45+ } ;
46+
47+
3948// TESTS //
4049
41- tape ( 'main export is a function' , function test ( t ) {
50+ tape ( 'main export is a function' , opts , function test ( t ) {
4251 t . ok ( true , __filename ) ;
4352 t . strictEqual ( typeof logpdf , 'function' , 'main export is a function' ) ;
4453 t . end ( ) ;
4554} ) ;
4655
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 ) {
4857 var y = logpdf ( NaN , 0.0 , 1.0 ) ;
4958 t . equal ( isnan ( y ) , true , 'returns NaN' ) ;
5059 y = logpdf ( 0.0 , NaN , 1.0 ) ;
@@ -54,19 +63,19 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', functio
5463 t . end ( ) ;
5564} ) ;
5665
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 ) {
5867 var y = logpdf ( PINF , 0.0 , 1.0 ) ;
5968 t . equal ( y , NINF , 'returns -infinity' ) ;
6069 t . end ( ) ;
6170} ) ;
6271
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 ) {
6473 var y = logpdf ( NINF , 0.0 , 1.0 ) ;
6574 t . equal ( y , NINF , 'returns -infinity' ) ;
6675 t . end ( ) ;
6776} ) ;
6877
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 ) {
7079 var y ;
7180
7281 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
9099 t . end ( ) ;
91100} ) ;
92101
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 ) {
94103 var y ;
95104
96105 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
111120 t . end ( ) ;
112121} ) ;
113122
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 ) {
115124 var expected ;
116125 var delta ;
117126 var tol ;
@@ -140,7 +149,7 @@ tape( 'the function evaluates the logpdf for `x` given positive `mu`', function
140149 t . end ( ) ;
141150} ) ;
142151
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 ) {
144153 var expected ;
145154 var delta ;
146155 var tol ;
@@ -169,7 +178,7 @@ tape( 'the function evaluates the logpdf for `x` given negative `mu`', function
169178 t . end ( ) ;
170179} ) ;
171180
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 ) {
173182 var expected ;
174183 var delta ;
175184 var tol ;
0 commit comments