|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2023 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 removeLast = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns a string... |
| 25 | +{ |
| 26 | + removeLast( 'abc', 1 ); // $ExpectType string |
| 27 | +} |
| 28 | + |
| 29 | +// The compiler throws an error if the function is provided a value other than a string... |
| 30 | +{ |
| 31 | + removeLast( true, 1 ); // $ExpectError |
| 32 | + removeLast( false, 1 ); // $ExpectError |
| 33 | + removeLast( null, 1 ); // $ExpectError |
| 34 | + removeLast( undefined, 1 ); // $ExpectError |
| 35 | + removeLast( 5, 1 ); // $ExpectError |
| 36 | + removeLast( [], 1 ); // $ExpectError |
| 37 | + removeLast( {}, 1 ); // $ExpectError |
| 38 | + removeLast( ( x: number ): number => x, 1 ); // $ExpectError |
| 39 | +} |
| 40 | + |
| 41 | +// The compiler throws an error if the function is provided a second argument that is not a number... |
| 42 | +{ |
| 43 | + removeLast( 'abc', true ); // $ExpectError |
| 44 | + removeLast( 'abc', false ); // $ExpectError |
| 45 | + removeLast( 'abc', null ); // $ExpectError |
| 46 | + removeLast( 'abc', 'abc' ); // $ExpectError |
| 47 | + removeLast( 'abc', [] ); // $ExpectError |
| 48 | + removeLast( 'abc', {} ); // $ExpectError |
| 49 | + removeLast( 'abc', ( x: number ): number => x ); // $ExpectError |
| 50 | +} |
| 51 | + |
| 52 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 53 | +{ |
| 54 | + removeLast(); // $ExpectError |
| 55 | + removeLast( 'abc' ); // $ExpectError |
| 56 | + removeLast( 'abc', 1, 2 ); // $ExpectError |
| 57 | +} |
0 commit comments