Skip to content
Draft
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
142 changes: 14 additions & 128 deletions lib/node_modules/@stdlib/math/base/special/cbrt/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -68,8 +66,6 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -78,21 +74,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-50,-500]'
x = veryLargeNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -101,21 +89,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[50,500]`',
x = veryLargePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -124,21 +104,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-50]`'
x = largeNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -147,21 +119,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[20,50]`',
x = largePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -170,21 +134,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-20,-3]`',
x = mediumNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -193,21 +149,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[3,20]`', o
x = mediumPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -216,21 +164,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-3,-0.8]`'
x = smallNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -239,21 +179,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[0.8,3]`',
x = smallPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -262,21 +194,13 @@ tape( 'the function evaluates cubic root of `x` on the interval `[-0.8,0.8]`', o
x = smaller.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1e-308]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -285,21 +209,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[-1e-300,-1
x = tinyNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e-308]`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -308,21 +224,13 @@ tape( 'the function evaluates the cubic root of `x` on the interval `[1e-300,1e-
x = tinyPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of subnormal `x`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -331,21 +239,13 @@ tape( 'the function evaluates the cubic root of subnormal `x`', opts, function t
x = subnormal.x;
for ( i = 0; i < x.length; i++ ) {
y = cbrt( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( y, expected[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the cubic root of `x` (huge negative)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -355,21 +255,13 @@ tape( 'the function evaluates the cubic root of `x` (huge negative)', opts, func

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

tape( 'the function evaluates the cubic root of `x` (huge positive)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -379,13 +271,7 @@ tape( 'the function evaluates the cubic root of `x` (huge positive)', opts, func

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