|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2021 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 shape2strides = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns an array of numbers... |
| 25 | +{ |
| 26 | + shape2strides( [ 3, 2, 1 ], 'row-major' ); // $ExpectType number[] |
| 27 | +} |
| 28 | + |
| 29 | +// The function does not compile if provided a first argument that is not an array-like object containing numbers... |
| 30 | +{ |
| 31 | + shape2strides( true, 'row-major' ); // $ExpectError |
| 32 | + shape2strides( false, 'row-major' ); // $ExpectError |
| 33 | + shape2strides( null, 'row-major' ); // $ExpectError |
| 34 | + shape2strides( undefined, 'row-major' ); // $ExpectError |
| 35 | + shape2strides( '5', 'row-major' ); // $ExpectError |
| 36 | + shape2strides( [ '1', '2' ], 'row-major' ); // $ExpectError |
| 37 | + shape2strides( {}, 'row-major' ); // $ExpectError |
| 38 | + shape2strides( ( x: number ): number => x, 'row-major' ); // $ExpectError |
| 39 | +} |
| 40 | + |
| 41 | +// The function does not compile if provided a second argument that is not a recognized order... |
| 42 | +{ |
| 43 | + shape2strides( [ 2, 3 ], true ); // $ExpectError |
| 44 | + shape2strides( [ 2, 3 ], false ); // $ExpectError |
| 45 | + shape2strides( [ 2, 3 ], null ); // $ExpectError |
| 46 | + shape2strides( [ 2, 3 ], undefined ); // $ExpectError |
| 47 | + shape2strides( [ 2, 3 ], '5' ); // $ExpectError |
| 48 | + shape2strides( [ 2, 3 ], [ '1', '2' ] ); // $ExpectError |
| 49 | + shape2strides( [ 2, 3 ], {} ); // $ExpectError |
| 50 | + shape2strides( [ 2, 3 ], ( x: number ): number => x ); // $ExpectError |
| 51 | +} |
| 52 | + |
| 53 | +// The function does not compile if provided insufficient arguments... |
| 54 | +{ |
| 55 | + shape2strides(); // $ExpectError |
| 56 | + shape2strides( [ 3, 2 ] ); // $ExpectError |
| 57 | +} |
0 commit comments