Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
63 changes: 7 additions & 56 deletions lib/node_modules/@stdlib/math/base/special/cos/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

var tape = require( 'tape' );
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 NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var cos = require( './../lib' );


Expand All @@ -49,8 +48,6 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function computes the cosine (medium negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -60,22 +57,14 @@ tape( 'the function computes the cosine (medium negative values)', function test

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
Comment thread
nirmaljb marked this conversation as resolved.
Outdated
}

t.end();
});

tape( 'the function computes the cosine (positive medium values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -85,22 +74,14 @@ tape( 'the function computes the cosine (positive medium values)', function test

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (large negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -110,22 +91,14 @@ tape( 'the function computes the cosine (large negative values)', function test(

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -135,22 +108,14 @@ tape( 'the function computes the cosine (large positive values)', function test(

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (huge negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -160,22 +125,14 @@ tape( 'the function computes the cosine (huge negative values)', function test(

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (huge positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -185,13 +142,7 @@ tape( 'the function computes the cosine (huge positive values)', function test(

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
Expand Down
64 changes: 7 additions & 57 deletions lib/node_modules/@stdlib/math/base/special/cos/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
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 NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var tryRequire = require( '@stdlib/utils/try-require' );


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

tape( 'the function computes the cosine (medium negative values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -69,22 +66,14 @@ tape( 'the function computes the cosine (medium negative values)', opts, functio

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (positive medium values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -94,22 +83,14 @@ tape( 'the function computes the cosine (positive medium values)', opts, functio

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (large negative values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -119,22 +100,14 @@ tape( 'the function computes the cosine (large negative values)', opts, function

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (large positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -144,22 +117,14 @@ tape( 'the function computes the cosine (large positive values)', opts, function

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (huge negative values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -169,22 +134,13 @@ tape( 'the function computes the cosine (huge negative values)', opts, function

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
});

tape( 'the function computes the cosine (huge positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -194,13 +150,7 @@ tape( 'the function computes the cosine (huge positive values)', opts, function

for ( i = 0; i < x.length; i++ ) {
y = cos( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. 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]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i] );
}

t.end();
Expand Down