|
22 | 22 |
|
23 | 23 | var tape = require( 'tape' );
|
24 | 24 | var isnan = require( '@stdlib/math/base/assert/is-nan' );
|
| 25 | +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); |
25 | 26 | var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
|
26 | 27 | var gsumkbn = require( './../lib/ndarray.js' );
|
27 | 28 |
|
@@ -93,6 +94,40 @@ tape( 'the function calculates the sum of all strided array elements (accessors)
|
93 | 94 | t.end();
|
94 | 95 | });
|
95 | 96 |
|
| 97 | +tape( 'the function does not preserve the sign of zero', function test( t ) { |
| 98 | + var x; |
| 99 | + var v; |
| 100 | + |
| 101 | + x = [ -0.0, -0.0, -0.0 ]; |
| 102 | + |
| 103 | + v = gsumkbn( x.length, x, 1, 0 ); |
| 104 | + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); |
| 105 | + |
| 106 | + x = [ 0.0, -0.0, -0.0 ]; |
| 107 | + |
| 108 | + v = gsumkbn( x.length, x, 1, 0 ); |
| 109 | + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); |
| 110 | + |
| 111 | + t.end(); |
| 112 | +}); |
| 113 | + |
| 114 | +tape( 'the function does not preserve the sign of zero (accessors)', function test( t ) { |
| 115 | + var x; |
| 116 | + var v; |
| 117 | + |
| 118 | + x = toAccessorArray( [ -0.0, -0.0, -0.0 ] ); |
| 119 | + |
| 120 | + v = gsumkbn( x.length, x, 1, 0 ); |
| 121 | + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); |
| 122 | + |
| 123 | + x = toAccessorArray( [ 0.0, -0.0, -0.0 ] ); |
| 124 | + |
| 125 | + v = gsumkbn( x.length, x, 1, 0 ); |
| 126 | + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); |
| 127 | + |
| 128 | + t.end(); |
| 129 | +}); |
| 130 | + |
96 | 131 | tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0.0`', function test( t ) {
|
97 | 132 | var x;
|
98 | 133 | var v;
|
|
0 commit comments