|
| 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 concat = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns a string... |
| 25 | +{ |
| 26 | + concat( 'beep', 'boop' ); // $ExpectType "beepboop" |
| 27 | + concat( 'foo', 'bar' ); // $ExpectType "foobar" |
| 28 | + concat( 'abc' as string, 'xyz' as string ); // $ExpectType string |
| 29 | +} |
| 30 | + |
| 31 | +// The compiler throws an error if the function is provided a first argument which is not a string... |
| 32 | +{ |
| 33 | + concat( true, 'boop' ); // $ExpectError |
| 34 | + concat( null, 'boop' ); // $ExpectError |
| 35 | + concat( undefined, 'boop' ); // $ExpectError |
| 36 | + concat( 123, 'boop' ); // $ExpectError |
| 37 | + concat( {}, 'boop' ); // $ExpectError |
| 38 | + concat( [], 'boop' ); // $ExpectError |
| 39 | + concat( ( x: number ): number => x, 'boop' ); // $ExpectError |
| 40 | +} |
| 41 | + |
| 42 | +// The compiler throws an error if the function is provided a second argument which is not a string... |
| 43 | +{ |
| 44 | + concat( 'beep', true ); // $ExpectError |
| 45 | + concat( 'beep', null ); // $ExpectError |
| 46 | + concat( 'beep', undefined ); // $ExpectError |
| 47 | + concat( 'beep', 123 ); // $ExpectError |
| 48 | + concat( 'beep', {} ); // $ExpectError |
| 49 | + concat( 'beep', [] ); // $ExpectError |
| 50 | + concat( 'beep', ( x: number ): number => x ); // $ExpectError |
| 51 | +} |
| 52 | + |
| 53 | +// The compiler throws an error if the function is provided insufficient arguments... |
| 54 | +{ |
| 55 | + concat(); // $ExpectError |
| 56 | + concat( 'beep' ); // $ExpectError |
| 57 | +} |
0 commit comments