|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2025 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 zeros = require( './../../../../base/zeros' ); |
| 20 | +import empty = require( './../../../../base/empty' ); |
| 21 | +import copy = require( './index' ); |
| 22 | + |
| 23 | + |
| 24 | +// TESTS // |
| 25 | + |
| 26 | +// The function returns an ndarray... |
| 27 | +{ |
| 28 | + const sh = [ 2, 2 ]; |
| 29 | + const ord = 'row-major'; |
| 30 | + |
| 31 | + copy( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray |
| 32 | + copy( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray |
| 33 | + copy( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray |
| 34 | + copy( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray |
| 35 | + copy( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray |
| 36 | + copy( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray |
| 37 | + copy( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray |
| 38 | + copy( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray |
| 39 | + copy( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray |
| 40 | + copy( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray |
| 41 | + copy( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray |
| 42 | + copy( empty( 'bool', sh, ord ) ); // $ExpectType boolndarray |
| 43 | + copy( zeros( 'generic', sh, ord ) ); // $ExpectType genericndarray<number> |
| 44 | +} |
| 45 | + |
| 46 | +// The compiler throws an error if the function is provided a first argument is not an ndarray... |
| 47 | +{ |
| 48 | + copy( '10' ); // $ExpectError |
| 49 | + copy( 10 ); // $ExpectError |
| 50 | + copy( false ); // $ExpectError |
| 51 | + copy( true ); // $ExpectError |
| 52 | + copy( null ); // $ExpectError |
| 53 | + copy( [] ); // $ExpectError |
| 54 | + copy( {} ); // $ExpectError |
| 55 | + copy( ( x: number ): number => x ); // $ExpectError |
| 56 | +} |
| 57 | + |
| 58 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 59 | +{ |
| 60 | + copy(); // $ExpectError |
| 61 | + copy( zeros( 'float64', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectError |
| 62 | +} |
0 commit comments