Skip to content

Commit 34e38bc

Browse files
MANDEep22332kgryte
andauthored
test: migrate math/base/special/binet to ULP-based testing
PR-URL: #11719 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Ref: #11352
1 parent 2e347f3 commit 34e38bc

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

  • lib/node_modules/@stdlib/math/base/special/binet/test

lib/node_modules/@stdlib/math/base/special/binet/test/test.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var PINF = require( '@stdlib/constants/float64/pinf' );
2626
var NINF = require( '@stdlib/constants/float64/ninf' );
27-
var EPS = require( '@stdlib/constants/float64/eps' );
27+
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
2828
var fibonacci = require( '@stdlib/math/base/special/fibonacci' );
2929
var negaFibonacci = require( '@stdlib/math/base/special/negafibonacci' );
30-
var abs = require( '@stdlib/math/base/special/abs' );
3130
var binet = require( './../lib' );
3231

3332

@@ -59,40 +58,24 @@ tape( 'if provided `-infinity`, the function returns `NaN`', function test( t )
5958

6059
tape( 'for nonnegative integers, the function approximates the nth Fibonacci number', function test( t ) {
6160
var expected;
62-
var delta;
63-
var tol;
6461
var v;
6562
var i;
6663
for ( i = 0; i < 79; i++ ) {
6764
v = binet( i );
6865
expected = fibonacci( i );
69-
if ( v === expected ) {
70-
t.strictEqual( v, expected, 'returns the '+i+'th Fibonacci number' );
71-
} else {
72-
delta = abs( v - expected );
73-
tol = 13.0 * EPS * abs( expected );
74-
t.strictEqual( delta <= tol, true, 'returns approximation. n: '+i+'. expected: '+expected+'. actual: '+v+'. Δ: '+delta+'. tol: '+tol+'.' );
75-
}
66+
t.strictEqual( isAlmostSameValue( v, expected, 24 ), true, 'returns expected value' );
7667
}
7768
t.end();
7869
});
7970

80-
tape( 'for nonpositive integers, the function approximates the nth negaFibonacci number', function test( t ) {
71+
tape( 'for nonpositive integers, the function approximates the nth negafibonacci number', function test( t ) {
8172
var expected;
82-
var delta;
83-
var tol;
8473
var v;
8574
var i;
8675
for ( i = 0; i > -79; i-- ) {
8776
v = binet( i );
8877
expected = negaFibonacci( i );
89-
if ( v === expected ) {
90-
t.strictEqual( v, expected, 'returns the '+i+'th negaFibonacci number' );
91-
} else {
92-
delta = abs( v - expected );
93-
tol = 12.0 * EPS * abs( expected );
94-
t.strictEqual( delta <= tol, true, 'returns approximation. n: '+i+'. expected: '+expected+'. actual: '+v+'. Δ: '+delta+'. tol: '+tol+'.' );
95-
}
78+
t.strictEqual( isAlmostSameValue( v, expected, 24 ), true, 'returns expected value' );
9679
}
9780
t.end();
9881
});

0 commit comments

Comments
 (0)