19
19
/// <reference types="@stdlib/types"/>
20
20
21
21
import zeros = require( '@stdlib/ndarray/zeros' ) ;
22
+ import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ) ;
22
23
import find = require( './index' ) ;
23
24
24
25
/**
@@ -34,14 +35,16 @@ function clbk( v: any ): boolean {
34
35
35
36
// TESTS //
36
37
37
- // The function returns a float64 ...
38
+ // The function returns a number ...
38
39
{
39
40
const x = zeros ( [ 2 , 2 ] ) ;
40
- const v = zeros ( [ ] ) ;
41
- const arrays = [ x , v ] ;
41
+ const sv = scalar2ndarray ( - 1.0 , {
42
+ 'dtype' : 'float64'
43
+ } ) ;
44
+ const arrays = [ x , sv ] ;
42
45
43
- find ( arrays , clbk ) ; // $ExpectType float64
44
- find ( arrays , clbk , { } ) ; // $ExpectType float64
46
+ find ( arrays , clbk ) ; // $ExpectType number
47
+ find ( arrays , clbk , { } ) ; // $ExpectType number
45
48
}
46
49
47
50
// The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarray-like objects...
@@ -68,8 +71,10 @@ function clbk( v: any ): boolean {
68
71
// The compiler throws an error if the function is provided a second argument which is not a callback function...
69
72
{
70
73
const x = zeros ( [ 2 , 2 ] ) ;
71
- const v = zeros ( [ ] ) ;
72
- const arrays = [ x , v ] ;
74
+ const sv = scalar2ndarray ( - 1.0 , {
75
+ 'dtype' : 'float64'
76
+ } ) ;
77
+ const arrays = [ x , sv ] ;
73
78
74
79
find ( arrays , '10' ) ; // $ExpectError
75
80
find ( arrays , 5 ) ; // $ExpectError
@@ -93,8 +98,10 @@ function clbk( v: any ): boolean {
93
98
// The compiler throws an error if the function is provided an unsupported number of arguments...
94
99
{
95
100
const x = zeros ( [ 2 , 2 ] ) ;
96
- const v = zeros ( [ ] ) ;
97
- const arrays = [ x , v ] ;
101
+ const sv = scalar2ndarray ( - 1.0 , {
102
+ 'dtype' : 'float64'
103
+ } ) ;
104
+ const arrays = [ x , sv ] ;
98
105
99
106
find ( ) ; // $ExpectError
100
107
find ( arrays ) ; // $ExpectError
0 commit comments