|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2025 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 AccessorArray = require( '@stdlib/array/base/accessor' ); |
| 20 | +import mskmin = require( './index' ); |
| 21 | + |
| 22 | + |
| 23 | +// TESTS // |
| 24 | + |
| 25 | +// The function returns a number... |
| 26 | +{ |
| 27 | + const x = new Float64Array( 10 ); |
| 28 | + const mask = new Uint8Array( 10 ); |
| 29 | + |
| 30 | + mskmin( x, mask ); // $ExpectType number |
| 31 | + mskmin( new AccessorArray( x ), mask ); // $ExpectType number |
| 32 | +} |
| 33 | + |
| 34 | +// The compiler throws an error if the function is provided a first argument which is not a numeric array... |
| 35 | +{ |
| 36 | + const mask = new Uint8Array( 10 ); |
| 37 | + |
| 38 | + mskmin( 10, mask ); // $ExpectError |
| 39 | + mskmin( '10', mask ); // $ExpectError |
| 40 | + mskmin( true, mask ); // $ExpectError |
| 41 | + mskmin( false, mask ); // $ExpectError |
| 42 | + mskmin( null, mask ); // $ExpectError |
| 43 | + mskmin( undefined, mask ); // $ExpectError |
| 44 | + mskmin( {}, mask ); // $ExpectError |
| 45 | + mskmin( ( x: number ): number => x, mask ); // $ExpectError |
| 46 | +} |
| 47 | + |
| 48 | +// The compiler throws an error if the function is provided a second argument which is not a numeric array... |
| 49 | +{ |
| 50 | + const x = new Float64Array( 10 ); |
| 51 | + |
| 52 | + mskmin( x, 10 ); // $ExpectError |
| 53 | + mskmin( x, '10' ); // $ExpectError |
| 54 | + mskmin( x, true ); // $ExpectError |
| 55 | + mskmin( x, false ); // $ExpectError |
| 56 | + mskmin( x, null ); // $ExpectError |
| 57 | + mskmin( x, undefined ); // $ExpectError |
| 58 | + mskmin( x, {} ); // $ExpectError |
| 59 | + mskmin( x, ( x: number ): number => x ); // $ExpectError |
| 60 | +} |
| 61 | + |
| 62 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 63 | +{ |
| 64 | + const x = new Float64Array( 10 ); |
| 65 | + const mask = new Uint8Array( 10 ); |
| 66 | + |
| 67 | + mskmin(); // $ExpectError |
| 68 | + mskmin( x ); // $ExpectError |
| 69 | + mskmin( x, mask, {} ); // $ExpectError |
| 70 | +} |
0 commit comments