|
23 | 23 | var tape = require( 'tape' ); |
24 | 24 | var isInfinite = require( '@stdlib/math/base/assert/is-infinite' ); |
25 | 25 | var isnan = require( '@stdlib/assert/is-nan' ); |
26 | | -var abs = require( '@stdlib/math/base/special/abs' ); |
| 26 | +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); |
27 | 27 | var PINF = require( '@stdlib/constants/float64/pinf' ); |
28 | | -var EPS = require( '@stdlib/constants/float64/eps' ); |
29 | 28 | var beta = require( './../lib' ); |
30 | 29 |
|
31 | 30 |
|
@@ -99,27 +98,19 @@ tape( 'the function evaluates the beta function (tested against R)', function te |
99 | 98 | y2 = isnan( expected1[ i ] ); |
100 | 99 | t.strictEqual( y1, y2, 'returned result is ' + ( (y1) ? '' : 'not' ) + ' NaN' ); |
101 | 100 | if ( !y1 ) { |
102 | | - t.ok( abs( actual - expected1[ i ] ) < 8e-15, 'returned result is within tolerance. actual: ' + actual + '; expected: ' + expected1[ i ] + '.' ); |
| 101 | + t.ok( Math.abs( actual - expected1[ i ] ) < 8e-15, 'returned result is within tolerance. actual: ' + actual + '; expected: ' + expected1[ i ] + '.' ); |
103 | 102 | } |
104 | 103 | } |
105 | 104 | t.end(); |
106 | 105 | }); |
107 | 106 |
|
108 | 107 | tape( 'the function evaluates the beta function (tested against Boost)', function test( t ) { |
109 | | - var delta; |
110 | | - var tol; |
111 | 108 | var i; |
112 | 109 | var y; |
113 | 110 |
|
114 | 111 | for ( i = 0; i < a2.length; i++ ) { |
115 | 112 | y = beta( a2[i], b2[i] ); |
116 | | - if ( y === expected2[i] ) { |
117 | | - t.strictEqual( y, expected2[i], 'y: '+y+'. a: '+a2[i]+'. b: '+b2[i]+', expected: '+expected2[i] ); |
118 | | - } else { |
119 | | - delta = abs( y - expected2[ i ] ); |
120 | | - tol = 160.0 * EPS * abs( expected2[ i ] ); |
121 | | - t.ok( delta <= tol, 'within tolerance. a: '+a2[i]+'. b: '+b2[i]+'. y: '+y+'. E: '+expected2[i]+'. Δ: '+delta+'. tol: '+tol ); |
122 | | - } |
| 113 | + t.strictEqual( isAlmostSameValue( y, expected2[ i ], 512 ), true, 'returns expected value' ); |
123 | 114 | } |
124 | 115 | t.end(); |
125 | 116 | }); |
0 commit comments