/* * @license Apache-2.0 * * Copyright (c) 2022 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( './../../../../base/zeros' ); import transpose = require( './index' ); // TESTS // // The function returns an ndarray... { const sh = [ 2, 2 ]; const ord = 'row-major'; transpose( zeros( 'float64', sh, ord ), false ); // $ExpectType float64ndarray transpose( zeros( 'float32', sh, ord ), false ); // $ExpectType float32ndarray transpose( zeros( 'complex128', sh, ord ), false ); // $ExpectType complex128ndarray transpose( zeros( 'complex64', sh, ord ), false ); // $ExpectType complex64ndarray transpose( zeros( 'int32', sh, ord ), false ); // $ExpectType int32ndarray transpose( zeros( 'int16', sh, ord ), false ); // $ExpectType int16ndarray transpose( zeros( 'int8', sh, ord ), false ); // $ExpectType int8ndarray transpose( zeros( 'uint32', sh, ord ), false ); // $ExpectType uint32ndarray transpose( zeros( 'uint16', sh, ord ), false ); // $ExpectType uint16ndarray transpose( zeros( 'uint8', sh, ord ), false ); // $ExpectType uint8ndarray transpose( zeros( 'uint8c', sh, ord ), false ); // $ExpectType uint8cndarray transpose( zeros( 'generic', sh, ord ), false ); // $ExpectType genericndarray } // The compiler throws an error if the function is provided a first argument which is not an ndarray... { transpose( '10', false ); // $ExpectError transpose( 10, false ); // $ExpectError transpose( false, false ); // $ExpectError transpose( true, false ); // $ExpectError transpose( null, false ); // $ExpectError transpose( void 0, false ); // $ExpectError transpose( [], false ); // $ExpectError transpose( {}, false ); // $ExpectError transpose( ( x: number ): number => x, false ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a boolean... { const x = zeros( 'float64', [ 2, 2 ], 'row-major' ); transpose( x, '5' ); // $ExpectError transpose( x, 5 ); // $ExpectError transpose( x, void 0 ); // $ExpectError transpose( x, null ); // $ExpectError transpose( x, {} ); // $ExpectError transpose( x, [] ); // $ExpectError transpose( x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { transpose(); // $ExpectError transpose( zeros( 'float64', [ 2, 2 ], 'row-major' ) ); // $ExpectError transpose( zeros( 'float64', [ 2, 2 ], 'row-major' ), false, {} ); // $ExpectError }