Skip to content
Closed
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
79 changes: 48 additions & 31 deletions lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ var isamax = require( './../lib/isamax.js' );

// TESTS //

tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof isamax, 'function', 'main export is a function' );
tape('main export is a function', function test(t) {
t.ok(true, __filename);
t.strictEqual(typeof isamax, 'function', 'main export is a function');
t.end();
});

tape( 'the function has an arity of 3', function test( t ) {
t.strictEqual( isamax.length, 3, 'returns expected value' );
tape('the function has an arity of 3', function test(t) {
t.strictEqual(isamax.length, 3, 'returns expected value');
t.end();
});

tape( 'the function finds the index of the element with the maximum absolute value', function test( t ) {
tape('the function finds the index of the element with the maximum absolute value', function test(t) {
var expected;
var idx;
var x;
Expand All @@ -54,43 +54,43 @@ tape( 'the function finds the index of the element with the maximum absolute val
]);
expected = 2;

idx = isamax( 4, x, 1 );
t.strictEqual( idx, expected, 'returns expected value' );
idx = isamax(4, x, 1);
t.strictEqual(idx, expected, 'returns expected value');

x = new Float32Array( [
x = new Float32Array([
0.2, // 1
-0.6, // 2
0.3, // 3
5.0,
5.0
] );
]);
expected = 1;

idx = isamax( 3, x, 1 );
t.strictEqual( idx, expected, 'returns expected value' );
idx = isamax(3, x, 1);
t.strictEqual(idx, expected, 'returns expected value');

t.end();
});

tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', function test( t ) {
tape('if provided an `N` parameter less than `1`, the function returns `-1`', function test(t) {
var expected;
var idx;
var x;

x = new Float32Array( [
x = new Float32Array([
1.0,
2.0,
3.0
] );
]);
expected = -1;

idx = isamax( 0, x, 1 );
t.strictEqual( idx, expected, 'returns expected value' );
idx = isamax(0, x, 1);
t.strictEqual(idx, expected, 'returns expected value');

t.end();
});

tape( 'the function supports specifying a stride', function test( t ) {
tape('the function supports specifying a stride', function test(t) {
var expected;
var idx;
var x;
Expand All @@ -107,28 +107,45 @@ tape( 'the function supports specifying a stride', function test( t ) {
]);
expected = 2;

idx = isamax( 4, x, 2 );
t.strictEqual( idx, expected, 'returns expected value' );
idx = isamax(4, x, 2);
t.strictEqual(idx, expected, 'returns expected value');
t.end();
});

tape( 'the function supports specifying a negative stride', function test( t ) {
tape('the function supports specifying a negative stride', function test(t) {
var idx;
var x;

x = new Float32Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] );
x = new Float32Array([3.0, -4.0, 1.0, 15.0, 4.0, 3.0]);

idx = isamax( x.length, x, -1 );
t.strictEqual( idx, 2, 'returns expected value' );
idx = isamax(x.length, x, -1);
t.strictEqual(idx, 2, 'returns expected value');

x = new Float32Array( [ 3.0, 999.9, 999.9, -4.0, 999.9, 999.9, 1.0, 999.9, 999.9, 15.0, 999.9, 999.9, 4.0, 999.9, 999.9, 3.0 ] );
idx = isamax( 6, x, -3 );
t.strictEqual( idx, 2, 'returns expected value' );
x = new Float32Array([
3.0,
999.9,
999.9,
-4.0,
999.9,
999.9,
1.0,
999.9,
999.9,
15.0,
999.9,
999.9,
4.0,
999.9,
999.9,
3.0
]);
idx = isamax(6, x, -3);
t.strictEqual(idx, 2, 'returns expected value');

t.end();
});

tape( 'the function supports view offsets', function test( t ) {
tape('the function supports view offsets', function test(t) {
var expected;
var idx;
var x0;
Expand All @@ -144,9 +161,9 @@ tape( 'the function supports view offsets', function test( t ) {
]);
expected = 2;

x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
x1 = new Float32Array(x0.buffer, x0.BYTES_PER_ELEMENT*1);

idx = isamax( 3, x1, 2 );
t.strictEqual( idx, expected, 'returns expected value' );
idx = isamax(3, x1, 2);
t.strictEqual(idx, expected, 'returns expected value');
t.end();
});