/* * @license Apache-2.0 * * Copyright (c) 2023 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. */ /* eslint-disable @typescript-eslint/no-unused-expressions */ import Slice = require( './index' ); // TESTS // // The function returns a slice... { new Slice(); // $ExpectType Slice new Slice( 10 ); // $ExpectType Slice new Slice( null ); // $ExpectType Slice new Slice( undefined ); // $ExpectType Slice new Slice( 3, 10 ); // $ExpectType Slice new Slice( null, 10 ); // $ExpectType Slice new Slice( undefined, 10 ); // $ExpectType Slice new Slice( 3, null ); // $ExpectType Slice new Slice( 3, undefined ); // $ExpectType Slice new Slice( null, null ); // $ExpectType Slice new Slice( undefined, undefined ); // $ExpectType Slice new Slice( 3, 10, 2 ); // $ExpectType Slice new Slice( null, 10, 2 ); // $ExpectType Slice new Slice( undefined, 10, 2 ); // $ExpectType Slice new Slice( 3, null, 2 ); // $ExpectType Slice new Slice( 3, undefined, 2 ); // $ExpectType Slice new Slice( 3, 10, null ); // $ExpectType Slice new Slice( 3, 10, undefined ); // $ExpectType Slice new Slice( null, null, 2 ); // $ExpectType Slice new Slice( undefined, undefined, 2 ); // $ExpectType Slice new Slice( null, 10, null ); // $ExpectType Slice new Slice( undefined, 10, undefined ); // $ExpectType Slice new Slice( 3, null, null ); // $ExpectType Slice new Slice( 3, undefined, undefined ); // $ExpectType Slice new Slice( null, null, null ); // $ExpectType Slice new Slice( undefined, undefined, undefined ); // $ExpectType Slice Slice(); // $ExpectType Slice Slice( 10 ); // $ExpectType Slice Slice( null ); // $ExpectType Slice Slice( undefined ); // $ExpectType Slice Slice( 3, 10 ); // $ExpectType Slice Slice( null, 10 ); // $ExpectType Slice Slice( undefined, 10 ); // $ExpectType Slice Slice( 3, null ); // $ExpectType Slice Slice( 3, undefined ); // $ExpectType Slice Slice( null, null ); // $ExpectType Slice Slice( undefined, undefined ); // $ExpectType Slice Slice( 3, 10, 2 ); // $ExpectType Slice Slice( null, 10, 2 ); // $ExpectType Slice Slice( undefined, 10, 2 ); // $ExpectType Slice Slice( 3, null, 2 ); // $ExpectType Slice Slice( 3, undefined, 2 ); // $ExpectType Slice Slice( 3, 10, null ); // $ExpectType Slice Slice( 3, 10, undefined ); // $ExpectType Slice Slice( null, null, 2 ); // $ExpectType Slice Slice( undefined, undefined, 2 ); // $ExpectType Slice Slice( null, 10, null ); // $ExpectType Slice Slice( undefined, 10, undefined ); // $ExpectType Slice Slice( 3, null, null ); // $ExpectType Slice Slice( 3, undefined, undefined ); // $ExpectType Slice Slice( null, null, null ); // $ExpectType Slice Slice( undefined, undefined, undefined ); // $ExpectType Slice } // The compiler throws an error if the function is provided an invalid first argument... { Slice( 'abc' ); // $ExpectError Slice( true ); // $ExpectError Slice( false ); // $ExpectError Slice( [] ); // $ExpectError Slice( {} ); // $ExpectError Slice( ( x: number ): number => x ); // $ExpectError Slice( 'abc', 2 ); // $ExpectError Slice( true, 2 ); // $ExpectError Slice( false, 2 ); // $ExpectError Slice( [], 2 ); // $ExpectError Slice( {}, 2 ); // $ExpectError Slice( ( x: number ): number => x, 2 ); // $ExpectError Slice( 'abc', null ); // $ExpectError Slice( true, null ); // $ExpectError Slice( false, null ); // $ExpectError Slice( [], null ); // $ExpectError Slice( {}, null ); // $ExpectError Slice( ( x: number ): number => x, null ); // $ExpectError Slice( 'abc', 2, 1 ); // $ExpectError Slice( true, 2, 1 ); // $ExpectError Slice( false, 2, 1 ); // $ExpectError Slice( [], 2, 1 ); // $ExpectError Slice( {}, 2, 1 ); // $ExpectError Slice( ( x: number ): number => x, 2, 1 ); // $ExpectError } // The compiler throws an error if the function is provided an invalid second argument... { Slice( 0, 'abc' ); // $ExpectError Slice( 0, true ); // $ExpectError Slice( 0, false ); // $ExpectError Slice( 0, [] ); // $ExpectError Slice( 0, {} ); // $ExpectError Slice( 0, ( x: number ): number => x ); // $ExpectError Slice( 0, 'abc', 2 ); // $ExpectError Slice( 0, true, 2 ); // $ExpectError Slice( 0, false, 2 ); // $ExpectError Slice( 0, [], 2 ); // $ExpectError Slice( 0, {}, 2 ); // $ExpectError Slice( 0, ( x: number ): number => x, 2 ); // $ExpectError Slice( 0, 'abc', null ); // $ExpectError Slice( 0, true, null ); // $ExpectError Slice( 0, false, null ); // $ExpectError Slice( 0, [], null ); // $ExpectError Slice( 0, {}, null ); // $ExpectError Slice( 0, ( x: number ): number => x, null ); // $ExpectError } // The compiler throws an error if the function is provided an invalid first argument... { Slice( 0, 10, 'abc' ); // $ExpectError Slice( 0, 10, true ); // $ExpectError Slice( 0, 10, false ); // $ExpectError Slice( 0, 10, [] ); // $ExpectError Slice( 0, 10, {} ); // $ExpectError Slice( 0, 10, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { Slice( 3, 10, 2, 1 ); // $ExpectError }