/* * @license Apache-2.0 * * Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /// import zeros = require( './../../../zeros' ); import concat = require( './index' ); // TESTS // // The function returns an ndarray... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); concat( [ x, y ] ); // $ExpectType typedndarray concat( [ x, y ], {} ); // $ExpectType typedndarray } // The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarrays... { concat( 5 ); // $ExpectError concat( true ); // $ExpectError concat( false ); // $ExpectError concat( null ); // $ExpectError concat( undefined ); // $ExpectError concat( [ 1 ] ); // $ExpectError concat( {} ); // $ExpectError concat( ( x: number ): number => x ); // $ExpectError concat( 5, {} ); // $ExpectError concat( true, {} ); // $ExpectError concat( false, {} ); // $ExpectError concat( null, {} ); // $ExpectError concat( undefined, {} ); // $ExpectError concat( [ 1 ], {} ); // $ExpectError concat( {}, {} ); // $ExpectError concat( ( x: number ): number => x, {} ); // $ExpectError } // The compiler throws an error if the function is provided an options argument which is not an object... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); concat( [ x, y ], '5' ); // $ExpectError concat( [ x, y ], 5 ); // $ExpectError concat( [ x, y ], true ); // $ExpectError concat( [ x, y ], false ); // $ExpectError concat( [ x, y ], null ); // $ExpectError concat( [ x, y ], [ 1 ] ); // $ExpectError concat( [ x, y ], ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an invalid `dim` option... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); concat( [ x, y ], { 'dim': '5'} ); // $ExpectError concat( [ x, y ], { 'dim': true} ); // $ExpectError concat( [ x, y ], { 'dim': false } ); // $ExpectError concat( [ x, y ], { 'dim': null } ); // $ExpectError concat( [ x, y ], { 'dim': [ 1 ] } ); // $ExpectError concat( [ x, y ], { 'dim': ( x: number ): number => x} ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); concat(); // $ExpectError concat( x ); // $ExpectError concat( [ x, y ], {}, {} ); // $ExpectError } // Attached to the function is an `assign` method which returns an ndarray... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); const z = zeros( [ 2, 5 ] ); concat.assign( [ x, y ], z ); // $ExpectType float64ndarray concat.assign( [ x, y ], z, {} ); // $ExpectType float64ndarray } // The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object containing ndarrays...... { const z = zeros( [ 2, 5 ] ); concat.assign( 5, z ); // $ExpectError concat.assign( true, z ); // $ExpectError concat.assign( false, z ); // $ExpectError concat.assign( null, z ); // $ExpectError concat.assign( undefined, z ); // $ExpectError concat.assign( [ 1 ], z ); // $ExpectError concat.assign( {}, z ); // $ExpectError concat.assign( ( x: number ): number => x, z ); // $ExpectError concat.assign( 5, z, {} ); // $ExpectError concat.assign( true, z, {} ); // $ExpectError concat.assign( false, z, {} ); // $ExpectError concat.assign( null, z, {} ); // $ExpectError concat.assign( undefined, z, {} ); // $ExpectError concat.assign( [ 1 ], z, {} ); // $ExpectError concat.assign( {}, z, {} ); // $ExpectError concat.assign( ( x: number ): number => x, z, {} ); // $ExpectError } // The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); concat.assign( [ x, y ], '5' ); // $ExpectError concat.assign( [ x, y ], 5 ); // $ExpectError concat.assign( [ x, y ], true ); // $ExpectError concat.assign( [ x, y ], false ); // $ExpectError concat.assign( [ x, y ], null ); // $ExpectError concat.assign( [ x, y ], [ 1 ] ); // $ExpectError concat.assign( [ x, y ], {} ); // $ExpectError concat.assign( [ x, y ], ( x: number ): number => x ); // $ExpectError concat.assign( [ x, y ], '5', {} ); // $ExpectError concat.assign( [ x, y ], 5, {} ); // $ExpectError concat.assign( [ x, y ], true, {} ); // $ExpectError concat.assign( [ x, y ], false, {} ); // $ExpectError concat.assign( [ x, y ], null, {} ); // $ExpectError concat.assign( [ x, y ], [ 1 ], {} ); // $ExpectError concat.assign( [ x, y ], {}, {} ); // $ExpectError concat.assign( [ x, y ], ( x: number ): number => x, {} ); // $ExpectError } // The compiler throws an error if the `assign` method is provided an options argument which is not an object... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); const z = zeros( [ 2, 5 ] ); concat.assign( [ x, y ], z, '5' ); // $ExpectError concat.assign( [ x, y ], z, 5 ); // $ExpectError concat.assign( [ x, y ], z, true ); // $ExpectError concat.assign( [ x, y ], z, false ); // $ExpectError concat.assign( [ x, y ], z, null ); // $ExpectError concat.assign( [ x, y ], z, [ 1 ] ); // $ExpectError concat.assign( [ x, y ], z, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an invalid `dim` option... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); const z = zeros( [ 2, 5 ] ); concat.assign( [ x, y ], z, { 'dim': '5'} ); // $ExpectError concat.assign( [ x, y ], z, { 'dim': true} ); // $ExpectError concat.assign( [ x, y ], z, { 'dim': false } ); // $ExpectError concat.assign( [ x, y ], z, { 'dim': null } ); // $ExpectError concat.assign( [ x, y ], z, { 'dim': [ 1 ] } ); // $ExpectError concat.assign( [ x, y ], z, { 'dim': ( x: number ): number => x} ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const x = zeros( [ 2, 2 ] ); const y = zeros( [ 2, 3 ] ); const z = zeros( [ 2, 5 ] ); concat.assign(); // $ExpectError concat.assign( [ x, y ] ); // $ExpectError concat.assign( [ x, y ], z, {}, {} ); // $ExpectError }