diff --git a/lib/node_modules/@stdlib/array/base/assert/has-same-values/lib/main.js b/lib/node_modules/@stdlib/array/base/assert/has-same-values/lib/main.js index b98e05a9d882..62d32db9ec6c 100644 --- a/lib/node_modules/@stdlib/array/base/assert/has-same-values/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/assert/has-same-values/lib/main.js @@ -22,9 +22,11 @@ var isComplex128Array = require( '@stdlib/array/base/assert/is-complex128array' ); var isComplex64Array = require( '@stdlib/array/base/assert/is-complex64array' ); +var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); var isSameValue = require( '@stdlib/assert/is-same-value' ); @@ -150,6 +152,13 @@ function hasSameValues( x, y ) { if ( xo.accessorProtocol || yo.accessorProtocol ) { FLG = 2; + // If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements... + if ( isBooleanArray( x ) ) { + if ( isBooleanArray( y ) ) { + return internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) ); + } + return accessors( xo, yo ); + } // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components... if ( isComplex128Array( x ) ) { xr = reinterpret128( x, 0 ); diff --git a/lib/node_modules/@stdlib/array/base/assert/has-same-values/test/test.js b/lib/node_modules/@stdlib/array/base/assert/has-same-values/test/test.js index 19ddf560565f..666657a455b1 100644 --- a/lib/node_modules/@stdlib/array/base/assert/has-same-values/test/test.js +++ b/lib/node_modules/@stdlib/array/base/assert/has-same-values/test/test.js @@ -25,6 +25,7 @@ var AccessorArray = require( '@stdlib/array/base/accessor' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); var hasSameValues = require( './../lib' ); @@ -111,6 +112,23 @@ tape( 'if provided empty collections, the function returns `true` (mixed)', func t.end(); }); +tape( 'if provided empty collections, the function returns `true` (boolean array)', function test( t ) { + var out; + var x; + var y; + + x = new BooleanArray( [] ); + out = hasSameValues( x, x ); + t.strictEqual( out, true, 'returns expected value' ); + + x = new BooleanArray( [] ); + y = new BooleanArray( [] ); + out = hasSameValues( x, y ); + t.strictEqual( out, true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided empty collections, the function returns `true` (complex typed array)', function test( t ) { var out; var x; @@ -206,6 +224,23 @@ tape( 'the function returns `true` if both arrays have the same values (mixed)', t.end(); }); +tape( 'the function returns `true` if both arrays have the same values (boolean array)', function test( t ) { + var out; + var x; + var y; + + x = new BooleanArray( [ true, false, true ] ); + out = hasSameValues( x, x ); + t.strictEqual( out, true, 'returns expected value' ); + + x = new BooleanArray( [ true, false, true ] ); + y = new BooleanArray( [ true, false, true ] ); + out = hasSameValues( x, y ); + t.strictEqual( out, true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `true` if both arrays have the same values (real typed array)', function test( t ) { var out; var x; @@ -330,6 +365,19 @@ tape( 'the function returns `false` if both arrays do not have the same values ( t.end(); }); +tape( 'the function returns `false` if both arrays do not have the same values (boolean array)', function test( t ) { + var out; + var x; + var y; + + x = new BooleanArray( [ true, false, false, true ] ); + y = new BooleanArray( [ true, true, false, false ] ); + out = hasSameValues( x, y ); + t.strictEqual( out, false, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `false` if both arrays do not have the same values (complex typed array)', function test( t ) { var out; var x;