Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var fallingFactorial = require( './../lib' );


Expand Down Expand Up @@ -91,8 +90,6 @@ tape( 'the function returns `+infinity` for small `x` and large `n`', function t

tape( 'the function evaluates the falling factorial for large `x`', function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -101,23 +98,16 @@ tape( 'the function evaluates the falling factorial for large `x`', function tes
expected = large.expected;
x = large.x;
n = large.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 80.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 116 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the falling factorial for small `x`', function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -126,23 +116,16 @@ tape( 'the function evaluates the falling factorial for small `x`', function tes
expected = small.expected;
x = small.x;
n = small.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 80.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 117 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the falling factorial for negative `x`', function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -151,15 +134,10 @@ tape( 'the function evaluates the falling factorial for negative `x`', function
expected = negative.expected;
x = negative.x;
n = negative.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 100.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 150 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -88,8 +87,6 @@ tape( 'the function returns `+infinity` for small `x` and large `n`', opts, func

tape( 'the function evaluates the falling factorial for large `x`', opts, function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -98,23 +95,16 @@ tape( 'the function evaluates the falling factorial for large `x`', opts, functi
expected = large.expected;
x = large.x;
n = large.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 80.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 116 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the falling factorial for small `x`', opts, function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -123,23 +113,16 @@ tape( 'the function evaluates the falling factorial for small `x`', opts, functi
expected = small.expected;
x = small.x;
n = small.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 80.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 117 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the falling factorial for negative `x`', opts, function test( t ) {
var expected;
var delta;
var tol;
var i;
var n;
var x;
Expand All @@ -148,15 +131,10 @@ tape( 'the function evaluates the falling factorial for negative `x`', opts, fun
expected = negative.expected;
x = negative.x;
n = negative.n;

for ( i = 0; i < x.length; i++ ) {
y = fallingFactorial( x[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+'. n: '+n[i]+', y: '+y+'. expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 100.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 150 ), true, 'returns expected value' );
}
t.end();
});