Skip to content

test: update test expected values #7449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
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
36 changes: 5 additions & 31 deletions lib/node_modules/@stdlib/blas/base/wasm/scnrm2/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,10 @@

var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
var scnrm2 = require( './../lib' );


// FUNCTIONS //

/**
* Tests for element approximate equality.
*
* @private
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
}


// TESTS //

tape( 'main export is an object', function test( t ) {
Expand All @@ -72,7 +46,7 @@ tape( 'the `main` method calculates the L2-norm of a vector', function test( t )
x = new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] );

nrm2 = scnrm2.main( x.length, x, 1 );
isApprox( t, nrm2, 11.575836902790, 1.0 );
t.strictEqual( nrm2, sqrtf( 134.0 ), 'returns expected value' );

x = new Complex64Array( [ -4.0, 0.0 ] );

Expand Down Expand Up @@ -100,7 +74,7 @@ tape( 'the `main` method supports a `stride` parameter', function test( t ) {
]);

nrm2 = scnrm2.main( 3, x, 2 );
isApprox( t, nrm2, 8.831760866327, 1.0 );
t.strictEqual( nrm2, sqrtf( 78.0 ), 'returns expected value' );

t.end();
});
Expand All @@ -119,7 +93,7 @@ tape( 'the `main` method supports a negative `stride` parameter', function test(
]);

nrm2 = scnrm2.main( 2, x, -2 );
isApprox( t, nrm2, 8.544003745317, 1.0 );
t.strictEqual( nrm2, sqrtf( 73.0 ), 'returns expected value' );

t.end();
});
Expand Down Expand Up @@ -160,7 +134,7 @@ tape( 'the `main` method supports view offsets', function test( t ) {
x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*2 ); // start at 3rd element

nrm2 = scnrm2.main( 2, x1, 2 );
isApprox( t, nrm2, 4.24264068711, 1.0 );
t.strictEqual( nrm2, sqrtf( 18.0 ), 'returns expected value' );

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,10 @@
var tape = require( 'tape' );
var Memory = require( '@stdlib/wasm/memory' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
var Module = require( './../lib' ).Module;


// FUNCTIONS //

/**
* Tests for element approximate equality.
*
* @private
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -92,7 +66,7 @@ tape( 'a module instance has a `main` method which calculates the L2-norm of a v
mod.write( xp, new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );

nrm2 = mod.main( 3, xp, 1 );
isApprox( t, nrm2, 11.575836902790, 1.0 );
t.strictEqual( nrm2, sqrtf( 134.0 ), 'returns expected value' );

// Short datasets:
xp = 0;
Expand Down Expand Up @@ -133,7 +107,7 @@ tape( 'a module instance has a `main` method which supports a `stride` parameter
]));

nrm2 = mod.main( 3, xp, 2 );
isApprox( t, nrm2, 8.831760866327, 1.0 );
t.strictEqual( nrm2, sqrtf( 78.0 ), 'returns expected value' );

t.end();
});
Expand Down Expand Up @@ -162,7 +136,7 @@ tape( 'a module instance has a `main` method which supports a negative `stride`
]));

nrm2 = mod.main( 2, xp, -2 );
isApprox( t, nrm2, 8.544003745317, 1.0 );
t.strictEqual( nrm2, sqrtf( 73.0 ), 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,10 @@
var tape = require( 'tape' );
var Memory = require( '@stdlib/wasm/memory' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
var Module = require( './../lib' ).Module;


// FUNCTIONS //

/**
* Tests for element approximate equality.
*
* @private
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
}


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -92,7 +66,7 @@ tape( 'a module instance has an `ndarray` method which calculates the L2-norm of
mod.write( xp, new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );

nrm2 = mod.ndarray( 3, xp, 1, 0 );
isApprox( t, nrm2, 11.575836902790, 1.0 );
t.strictEqual( nrm2, sqrtf( 134.0 ), 'returns expected value' );

// Short datasets:
xp = 0;
Expand Down Expand Up @@ -133,7 +107,7 @@ tape( 'a module instance has an `ndarray` method which supports a `stride` param
]));

nrm2 = mod.ndarray( 3, xp, 2, 0 );
isApprox( t, nrm2, 8.831760866327, 1.0 );
t.strictEqual( nrm2, sqrtf( 78.0 ), 'returns expected value' );

t.end();
});
Expand Down Expand Up @@ -164,7 +138,7 @@ tape( 'a module instance has an `ndarray` method which supports a negative `stri
]));

nrm2 = mod.ndarray( 2, xp, -2, 3 );
isApprox( t, nrm2, 8.544003745317, 1.0 );
t.strictEqual( nrm2, sqrtf( 73.0 ), 'returns expected value' );

t.end();
});
Expand Down Expand Up @@ -197,7 +171,7 @@ tape( 'a module instance has an `ndarray` method which supports an `x` offset',
]));

nrm2 = mod.ndarray( 2, xp, 2, 2 );
isApprox( t, nrm2, 4.24264068711, 1.0 );
t.strictEqual( nrm2, sqrtf( 18.0 ), 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,10 @@

var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
var scnrm2 = require( './../lib' );


// FUNCTIONS //

/**
* Tests for element approximate equality.
*
* @private
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
}


// TESTS //

tape( 'main export is an object', function test( t ) {
Expand All @@ -72,7 +46,7 @@ tape( 'the `ndarray` method calculates the L2-norm of a vector', function test(
x = new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] );

nrm2 = scnrm2.ndarray( x.length, x, 1, 0 );
isApprox( t, nrm2, 11.575836902790, 1.0 );
t.strictEqual( nrm2, sqrtf( 134.0 ), 'returns expected value' );

// Short datasets:
x = new Complex64Array( [ -4.0, 0.0 ] );
Expand Down Expand Up @@ -101,7 +75,7 @@ tape( 'the `ndarray` method supports a `stride` parameter', function test( t ) {
]);

nrm2 = scnrm2.ndarray( 3, x, 2, 0 );
isApprox( t, nrm2, 8.831760866327, 1.0 );
t.strictEqual( nrm2, sqrtf( 78.0 ), 'returns expected value' );

t.end();
});
Expand All @@ -122,7 +96,7 @@ tape( 'the `ndarray` method supports a negative stride parameter', function test
]);

nrm2 = scnrm2.ndarray( 2, x, -2, x.length-1);
isApprox( t, nrm2, 8.544003745317, 1.0 );
t.strictEqual( nrm2, sqrtf( 73.0 ), 'returns expected value' );

t.end();
});
Expand All @@ -145,7 +119,7 @@ tape( 'the `ndarray` method supports an `offset` parameter', function test( t )
]);

nrm2 = scnrm2.ndarray( 2, x, 2, 2 );
isApprox( t, nrm2, 4.24264068711, 1.0 );
t.strictEqual( nrm2, sqrtf( 18.0 ), 'returns expected value' );

t.end();
});
Expand Down