|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2024 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +import toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); |
| 20 | +import hasSameValues = require( './index' ); |
| 21 | + |
| 22 | + |
| 23 | +// TESTS // |
| 24 | + |
| 25 | +// The function returns a boolean... |
| 26 | +{ |
| 27 | + const x = [ 1, 2, 3 ]; |
| 28 | + |
| 29 | + hasSameValues( x, x ); // $ExpectType boolean |
| 30 | + hasSameValues( new Float64Array( x ), new Float64Array( x ) ); // $ExpectType boolean |
| 31 | + hasSameValues( new Float32Array( x ), new Float32Array( x ) ); // $ExpectType boolean |
| 32 | + hasSameValues( new Int32Array( x ), new Int32Array( x ) ); // $ExpectType boolean |
| 33 | + hasSameValues( new Int16Array( x ), new Int16Array( x ) ); // $ExpectType boolean |
| 34 | + hasSameValues( new Int8Array( x ), new Int8Array( x ) ); // $ExpectType boolean |
| 35 | + hasSameValues( new Uint32Array( x ), new Uint32Array( x ) ); // $ExpectType boolean |
| 36 | + hasSameValues( new Uint16Array( x ), new Uint16Array( x ) ); // $ExpectType boolean |
| 37 | + hasSameValues( new Uint8Array( x ), new Uint8Array( x ) ); // $ExpectType boolean |
| 38 | + hasSameValues( new Uint8ClampedArray( x ), new Uint8ClampedArray( x ) ); // $ExpectType boolean |
| 39 | + hasSameValues( toAccessorArray( x ), toAccessorArray( x ) ); // $ExpectType boolean |
| 40 | +} |
| 41 | + |
| 42 | +// The compiler throws an error if the function is provided a first argument which is not a collection... |
| 43 | +{ |
| 44 | + const x = [ 1, 2, 3 ]; |
| 45 | + |
| 46 | + hasSameValues( 2, x ); // $ExpectError |
| 47 | + hasSameValues( false, x ); // $ExpectError |
| 48 | + hasSameValues( true, x ); // $ExpectError |
| 49 | + hasSameValues( {}, x ); // $ExpectError |
| 50 | +} |
| 51 | + |
| 52 | +// The compiler throws an error if the function is provided a second argument which is not a collection... |
| 53 | +{ |
| 54 | + const x = [ 1, 2, 3 ]; |
| 55 | + |
| 56 | + hasSameValues( x, 2 ); // $ExpectError |
| 57 | + hasSameValues( x, false ); // $ExpectError |
| 58 | + hasSameValues( x, true ); // $ExpectError |
| 59 | + hasSameValues( x, {} ); // $ExpectError |
| 60 | +} |
| 61 | + |
| 62 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 63 | +{ |
| 64 | + const x = [ 1, 2, 3 ]; |
| 65 | + |
| 66 | + hasSameValues(); // $ExpectError |
| 67 | + hasSameValues( x ); // $ExpectError |
| 68 | + hasSameValues( x, x, x ); // $ExpectError |
| 69 | +} |
0 commit comments