/* * @license Apache-2.0 * * Copyright (c) 2026 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( './../../../../base/zeros' ); import broadcastScalarLike = require( './index' ); // TESTS // // The function returns an ndarray... { broadcastScalarLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), 1.0 ); // $ExpectType float64ndarray broadcastScalarLike( zeros( 'float32', [ 2, 2 ], 'row-major' ), 1.0 ); // $ExpectType float32ndarray broadcastScalarLike( zeros( 'complex128', [ 2, 2 ], 'row-major' ), 1.0 ); // $ExpectType complex128ndarray broadcastScalarLike( zeros( 'complex64', [ 2, 2 ], 'row-major' ), 1.0 ); // $ExpectType complex64ndarray broadcastScalarLike( zeros( 'int32', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType int32ndarray broadcastScalarLike( zeros( 'int16', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType int16ndarray broadcastScalarLike( zeros( 'int8', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType int8ndarray broadcastScalarLike( zeros( 'uint32', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType uint32ndarray broadcastScalarLike( zeros( 'uint16', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType uint16ndarray broadcastScalarLike( zeros( 'uint8', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType uint8ndarray broadcastScalarLike( zeros( 'uint8c', [ 2, 2 ], 'row-major' ), 1 ); // $ExpectType uint8cndarray broadcastScalarLike( zeros( 'generic', [ 2, 2 ], 'row-major' ), 1.0 ); // $ExpectType genericndarray } // The compiler throws an error if the function is provided a first argument which is not an ndarray... { broadcastScalarLike( '5', 1.0 ); // $ExpectError broadcastScalarLike( 5, 1.0 ); // $ExpectError broadcastScalarLike( true, 1.0 ); // $ExpectError broadcastScalarLike( false, 1.0 ); // $ExpectError broadcastScalarLike( null, 1.0 ); // $ExpectError broadcastScalarLike( [], 1.0 ); // $ExpectError broadcastScalarLike( {}, 1.0 ); // $ExpectError broadcastScalarLike( ( x: number ): number => x, 1.0 ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { broadcastScalarLike(); // $ExpectError broadcastScalarLike( zeros( 'float64', [ 2, 2 ], 'row-major' ) ); // $ExpectError broadcastScalarLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), 1.0, {} ); // $ExpectError }