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
81 changes: 14 additions & 67 deletions lib/node_modules/@stdlib/math/base/special/sec/test/test.js
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 PI = require( '@stdlib/constants/float64/pi' );
var EPS = require( '@stdlib/constants/float64/eps' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var sec = require( './../lib' );
Expand Down Expand Up @@ -57,8 +56,6 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function computes the secant (huge negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -71,18 +68,14 @@ tape( 'the function computes the secant (huge negative values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (huge positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -95,18 +88,14 @@ tape( 'the function computes the secant (huge positive values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (very large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -119,18 +108,14 @@ tape( 'the function computes the secant (very large positive values)', function
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (very large negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -143,18 +128,14 @@ tape( 'the function computes the secant (very large negative values)', function
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -167,18 +148,14 @@ tape( 'the function computes the secant (large positive values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (large negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -191,18 +168,14 @@ tape( 'the function computes the secant (large negative values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (medium positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -215,18 +188,14 @@ tape( 'the function computes the secant (medium positive values)', function test
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (medium negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -239,18 +208,14 @@ tape( 'the function computes the secant (medium negative values)', function test
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (small positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -263,18 +228,14 @@ tape( 'the function computes the secant (small positive values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ]);
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (small negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -287,18 +248,14 @@ tape( 'the function computes the secant (small negative values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ]);
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (smaller values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -311,18 +268,14 @@ tape( 'the function computes the secant (smaller values)', function test( t ) {
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (tiny positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -335,18 +288,14 @@ tape( 'the function computes the secant (tiny positive values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the secant (tiny negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -359,9 +308,7 @@ tape( 'the function computes the secant (tiny negative values)', function test(
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: ' + x[ i ] + '. E: ' + expected[ i ] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
}
t.end();
Expand Down
Loading