|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2021 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 wrapIndex = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns a number... |
| 25 | +{ |
| 26 | + wrapIndex( 15, 10 ); // $ExpectType number |
| 27 | +} |
| 28 | + |
| 29 | +// The function does not compile if provided values other than two numbers... |
| 30 | +{ |
| 31 | + wrapIndex( true, 3 ); // $ExpectError |
| 32 | + wrapIndex( false, 2 ); // $ExpectError |
| 33 | + wrapIndex( '5', 1 ); // $ExpectError |
| 34 | + wrapIndex( [], 1 ); // $ExpectError |
| 35 | + wrapIndex( {}, 2 ); // $ExpectError |
| 36 | + wrapIndex( ( x: number ): number => x, 2 ); // $ExpectError |
| 37 | + |
| 38 | + wrapIndex( 9, true ); // $ExpectError |
| 39 | + wrapIndex( 9, false ); // $ExpectError |
| 40 | + wrapIndex( 5, '5' ); // $ExpectError |
| 41 | + wrapIndex( 8, [] ); // $ExpectError |
| 42 | + wrapIndex( 9, {} ); // $ExpectError |
| 43 | + wrapIndex( 8, ( x: number ): number => x ); // $ExpectError |
| 44 | + |
| 45 | + wrapIndex( [], true ); // $ExpectError |
| 46 | + wrapIndex( {}, false ); // $ExpectError |
| 47 | + wrapIndex( false, '5' ); // $ExpectError |
| 48 | + wrapIndex( {}, [] ); // $ExpectError |
| 49 | + wrapIndex( '5', ( x: number ): number => x ); // $ExpectError |
| 50 | +} |
| 51 | + |
| 52 | +// The function does not compile if provided insufficient arguments... |
| 53 | +{ |
| 54 | + wrapIndex(); // $ExpectError |
| 55 | + wrapIndex( 3 ); // $ExpectError |
| 56 | +} |
0 commit comments