|
| 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 Complex128Array = require( '@stdlib/array/complex128' ); |
| 20 | +import Complex64Array = require( '@stdlib/array/complex64' ); |
| 21 | +import join = require( './index' ); |
| 22 | + |
| 23 | + |
| 24 | +// TESTS // |
| 25 | + |
| 26 | +// The function returns an array... |
| 27 | +{ |
| 28 | + join( [ 1, 2, 3 ], ',' ); // $ExpectType string |
| 29 | + join( new Float64Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 30 | + join( new Float32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 31 | + join( new Int32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 32 | + join( new Int16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 33 | + join( new Int8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 34 | + join( new Uint32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 35 | + join( new Uint16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 36 | + join( new Uint8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 37 | + join( new Uint8ClampedArray( [ 1, 2, 3 ] ), ',' ); // $ExpectType string |
| 38 | + join( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string |
| 39 | + join( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string |
| 40 | +} |
| 41 | + |
| 42 | +// The compiler throws an error if the function is provided a first argument which is not a collection... |
| 43 | +{ |
| 44 | + join( 5, ',' ); // $ExpectError |
| 45 | + join( true, ',' ); // $ExpectError |
| 46 | + join( false, ',' ); // $ExpectError |
| 47 | + join( null, ',' ); // $ExpectError |
| 48 | + join( void 0, ',' ); // $ExpectError |
| 49 | + join( {}, ',' ); // $ExpectError |
| 50 | +} |
| 51 | + |
| 52 | +// The compiler throws an error if the function is provided a second argument which is not a string... |
| 53 | +{ |
| 54 | + const x = [ 1, 2, 3 ]; |
| 55 | + |
| 56 | + join( x, true ); // $ExpectError |
| 57 | + join( x, false ); // $ExpectError |
| 58 | + join( x, null ); // $ExpectError |
| 59 | + join( x, {} ); // $ExpectError |
| 60 | + join( x, ( x: number ): number => x ); // $ExpectError |
| 61 | +} |
| 62 | + |
| 63 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 64 | +{ |
| 65 | + join(); // $ExpectError |
| 66 | + join( [ 1, 2, 3 ] ); // $ExpectError |
| 67 | + join( [ 1, 2, 3 ], 0, 3, {} ); // $ExpectError |
| 68 | +} |
0 commit comments