/* * @license Apache-2.0 * * Copyright (c) 2026 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 empty = require( './../../../empty' ); import toReversedDimension = require( './index' ); // TESTS // // The function returns an ndarray... { var x = empty( [ 2, 2 ] ); toReversedDimension( x ); // $ExpectType float64ndarray toReversedDimension( x, {} ); // $ExpectType float64ndarray } // The compiler throws an error if the function is provided a first argument which is not an ndarray... { toReversedDimension( '10' ); // $ExpectError toReversedDimension( 10 ); // $ExpectError toReversedDimension( false ); // $ExpectError toReversedDimension( true ); // $ExpectError toReversedDimension( null ); // $ExpectError toReversedDimension( [] ); // $ExpectError toReversedDimension( {} ); // $ExpectError toReversedDimension( ( x: number ): number => x ); // $ExpectError toReversedDimension( '10', {} ); // $ExpectError toReversedDimension( 10, {} ); // $ExpectError toReversedDimension( false, {} ); // $ExpectError toReversedDimension( true, {} ); // $ExpectError toReversedDimension( null, {} ); // $ExpectError toReversedDimension( [], {} ); // $ExpectError toReversedDimension( {}, {} ); // $ExpectError toReversedDimension( ( 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 = empty( [ 2, 2 ] ); toReversedDimension( x, '5' ); // $ExpectError toReversedDimension( x, true ); // $ExpectError toReversedDimension( x, false ); // $ExpectError toReversedDimension( x, null ); // $ExpectError toReversedDimension( x, [ '5' ] ); // $ExpectError toReversedDimension( x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided a `dim` option which is not a number... { const x = empty( [ 2, 2 ] ); toReversedDimension( x, { 'dim': '5' } ); // $ExpectError toReversedDimension( x, { 'dim': true } ); // $ExpectError toReversedDimension( x, { 'dim': false } ); // $ExpectError toReversedDimension( x, { 'dim': null } ); // $ExpectError toReversedDimension( x, { 'dim': [ '5' ] } ); // $ExpectError toReversedDimension( x, { 'dim': {} } ); // $ExpectError toReversedDimension( x, { 'dim': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const x = empty( [ 2, 2 ] ); toReversedDimension(); // $ExpectError toReversedDimension( x, {}, {} ); // $ExpectError }