|
| 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 minmaxViewBufferIndex = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns an array of numbers... |
| 25 | +{ |
| 26 | + minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] |
| 27 | +} |
| 28 | + |
| 29 | +// The function does not compile if provided a first argument which is not an array-like object containing numbers... |
| 30 | +{ |
| 31 | + const strides = [ 10, 1 ]; |
| 32 | + const offset = 10; |
| 33 | + minmaxViewBufferIndex( true, strides, offset ); // $ExpectError |
| 34 | + minmaxViewBufferIndex( false, strides, offset ); // $ExpectError |
| 35 | + minmaxViewBufferIndex( null, strides, offset ); // $ExpectError |
| 36 | + minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError |
| 37 | + minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError |
| 38 | + minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError |
| 39 | + minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError |
| 40 | + minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError |
| 41 | +} |
| 42 | + |
| 43 | +// The function does not compile if provided a second argument which is not an array-like object containing numbers... |
| 44 | +{ |
| 45 | + const shape = [ 10, 10 ]; |
| 46 | + const offset = 10; |
| 47 | + minmaxViewBufferIndex( shape, true, offset ); // $ExpectError |
| 48 | + minmaxViewBufferIndex( shape, false, offset ); // $ExpectError |
| 49 | + minmaxViewBufferIndex( shape, null, offset ); // $ExpectError |
| 50 | + minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError |
| 51 | + minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError |
| 52 | + minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError |
| 53 | + minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError |
| 54 | + minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError |
| 55 | +} |
| 56 | + |
| 57 | +// The function does not compile if provided a third argument which is not a number... |
| 58 | +{ |
| 59 | + const shape = [ 10, 10 ]; |
| 60 | + const strides = [ 10, 1 ]; |
| 61 | + minmaxViewBufferIndex( shape, strides, true ); // $ExpectError |
| 62 | + minmaxViewBufferIndex( shape, strides, false ); // $ExpectError |
| 63 | + minmaxViewBufferIndex( shape, strides, null ); // $ExpectError |
| 64 | + minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError |
| 65 | + minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError |
| 66 | + minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError |
| 67 | + minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError |
| 68 | + minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError |
| 69 | +} |
| 70 | + |
| 71 | +// The function does not compile if provided insufficient arguments... |
| 72 | +{ |
| 73 | + minmaxViewBufferIndex(); // $ExpectError |
| 74 | + minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError |
| 75 | + minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError |
| 76 | +} |
0 commit comments