/* * @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 copy = require( './index' ); // TESTS // // The function returns an ndarray... { copy( zeros( [ 2, 2 ] ) ); // $ExpectType float64ndarray copy( zeros( [ 2, 2 ] ), {} ); // $ExpectType float64ndarray copy( zeros( [ 2, 2 ] ), { 'order': 'column-major' } ); // $ExpectType float64ndarray copy( zeros( [ 2, 2] ), { 'dtype': 'float64' } ); // $ExpectType ndarray } // The compiler throws an error if the function is provided a first argument which is not an ndarray-like object... { copy( '10' ); // $ExpectError copy( 10 ); // $ExpectError copy( false ); // $ExpectError copy( true ); // $ExpectError copy( null ); // $ExpectError copy( [] ); // $ExpectError copy( {} ); // $ExpectError copy( ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided a second argument is not an options object... { const x = zeros( [ 2, 2 ] ); copy( x, '10' ); // $ExpectError copy( x, 10 ); // $ExpectError copy( x, false ); // $ExpectError copy( x, true ); // $ExpectError copy( x, [] ); // $ExpectError copy( x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided a `dtype` option which is not a valid data type... { const x = zeros( [ 2, 2 ] ); copy( x, { 'dtype': '10' } ); // $ExpectError copy( x, { 'dtype': 10 } ); // $ExpectError copy( x, { 'dtype': null } ); // $ExpectError copy( x, { 'dtype': false } ); // $ExpectError copy( x, { 'dtype': true } ); // $ExpectError copy( x, { 'dtype': [] } ); // $ExpectError copy( x, { 'dtype': {} } ); // $ExpectError copy( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the function is provided an `order` option which is not a valid order... { const x = zeros( [ 2, 2 ] ); copy( x, { 'order': '10' } ); // $ExpectError copy( x, { 'order': 10 } ); // $ExpectError copy( x, { 'order': false } ); // $ExpectError copy( x, { 'order': true } ); // $ExpectError copy( x, { 'order': [] } ); // $ExpectError copy( x, { 'order': {} } ); // $ExpectError copy( x, { 'order': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the function is provided a `mode` option which is not a valid mode... { const x = zeros( [ 2, 2 ] ); copy( x, { 'mode': '5' } ); // $ExpectError copy( x, { 'mode': 5 } ); // $ExpectError copy( x, { 'mode': false } ); // $ExpectError copy( x, { 'mode': true } ); // $ExpectError copy( x, { 'mode': [ '5' ] } ); // $ExpectError copy( x, { 'mode': {} } ); // $ExpectError copy( x, { 'mode': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the function is provided a `submode` option which is not valid... { const x = zeros( [ 2, 2 ] ); copy( x, { 'submode': '5' } ); // $ExpectError copy( x, { 'submode': 5 } ); // $ExpectError copy( x, { 'submode': false } ); // $ExpectError copy( x, { 'submode': true } ); // $ExpectError copy( x, { 'submode': [ '5' ] } ); // $ExpectError copy( x, { 'submode': {} } ); // $ExpectError copy( x, { 'submode': ( x: number ): number => x } ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { copy(); // $ExpectError copy( zeros( [ 2, 2 ] ), {}, 1 ); // $ExpectError }