From 297cdffbf14b0f7cd87b0455b00d4a4fbf3b6cc3 Mon Sep 17 00:00:00 2001 From: Saurabh Singh Date: Thu, 21 Nov 2024 08:05:58 +0530 Subject: [PATCH] test: add tests to blas/ext/base/dnannsumbn2 PR-URL: https://github.com/stdlib-js/stdlib/pull/3205 Closes: https://github.com/stdlib-js/stdlib/issues/3186 Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt Signed-off-by: Philipp Burckhardt --- .../base/dnannsumkbn2/test/test.dnannsumkbn2.js | 16 ++++++++++++++++ .../test/test.dnannsumkbn2.native.js | 16 ++++++++++++++++ .../ext/base/dnannsumkbn2/test/test.ndarray.js | 16 ++++++++++++++++ .../dnannsumkbn2/test/test.ndarray.native.js | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.js index a2440f1e6684..12325cd3a4fa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.js @@ -231,6 +231,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); +tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); + out = new Float64Array( 2 ); + v = dnannsumkbn2( x.length, x, 0, out, 1 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var expected0; var expected1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.native.js index 77f39cba8257..295ce6bce924 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.dnannsumkbn2.native.js @@ -240,6 +240,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); +tape( 'if provided a `stride` parameter equal to `0` and the first element is NaN, the function returns `0.0`', opts, function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ NaN, 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 2 ); + v = dnannsumkbn2( x.length, x, 0, out, 1 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', opts, function test( t ) { var expected0; var expected1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.js index ac7034349bfa..d1ba3f7a25d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.js @@ -231,6 +231,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); +tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); + out = new Float64Array( 2 ); + v = dnannsumkbn2( x.length, x, 0, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports `offset` parameters', function test( t ) { var expected; var out; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.native.js index edc27ee55ece..f0297a7b3d71 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/test/test.ndarray.native.js @@ -240,6 +240,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s t.end(); }); +tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns `0.0`', opts, function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] ); + out = new Float64Array( 2 ); + v = dnannsumkbn2( x.length, x, 0, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports `offset` parameters', opts, function test( t ) { var expected; var out;