@@ -560,6 +560,10 @@ func testGoCallable(t *testing.T, tests []goCallableTest) {
560
560
if argc := len (test .Args ); argc > 0 {
561
561
argv = make ([]reflect.Value , argc )
562
562
for i := range argv {
563
+ if test .Args [i ] == nil {
564
+ argv [i ] = nullValue ()
565
+ continue
566
+ }
563
567
argv [i ] = reflect .ValueOf (test .Args [i ])
564
568
}
565
569
}
@@ -1402,7 +1406,7 @@ func TestLambdaCallable(t *testing.T) {
1402
1406
},
1403
1407
},
1404
1408
Args : []interface {}{
1405
- null ,
1409
+ nil ,
1406
1410
},
1407
1411
Error : & ArgTypeError {
1408
1412
Func : "boolean2" ,
@@ -1811,48 +1815,55 @@ func testLambdaCallable(t *testing.T, tests []lambdaCallableTest) {
1811
1815
1812
1816
for i , test := range tests {
1813
1817
1814
- env := newEnvironment (nil , len (test .Vars ))
1815
- for name , v := range test .Vars {
1816
- env .bind (name , reflect .ValueOf (v ))
1817
- }
1818
+ t .Run (test .Name , func (t * testing.T ) {
1818
1819
1819
- f := & lambdaCallable {
1820
- callableName : callableName {
1821
- name : test .Name ,
1822
- },
1823
- body : test .Body ,
1824
- paramNames : test .ParamNames ,
1825
- typed : test .Typed ,
1826
- params : test .Params ,
1827
- env : env ,
1828
- context : reflect .ValueOf (test .Context ),
1829
- }
1820
+ env := newEnvironment (nil , len (test .Vars ))
1821
+ for name , v := range test .Vars {
1822
+ env .bind (name , reflect .ValueOf (v ))
1823
+ }
1830
1824
1831
- var args []reflect.Value
1832
- for _ , arg := range test .Args {
1833
- args = append (args , reflect .ValueOf (arg ))
1834
- }
1825
+ f := & lambdaCallable {
1826
+ callableName : callableName {
1827
+ name : test .Name ,
1828
+ },
1829
+ body : test .Body ,
1830
+ paramNames : test .ParamNames ,
1831
+ typed : test .Typed ,
1832
+ params : test .Params ,
1833
+ env : env ,
1834
+ context : reflect .ValueOf (test .Context ),
1835
+ }
1835
1836
1836
- v , err := f .Call (args )
1837
+ var args []reflect.Value
1838
+ for _ , arg := range test .Args {
1839
+ if arg == nil {
1840
+ args = append (args , nullValue ())
1841
+ continue
1842
+ }
1843
+ args = append (args , reflect .ValueOf (arg ))
1844
+ }
1837
1845
1838
- var output interface {}
1839
- if v .IsValid () && v .CanInterface () {
1840
- output = v .Interface ()
1841
- }
1846
+ v , err := f .Call (args )
1842
1847
1843
- if test . Undefined {
1844
- if v != undefined {
1845
- t . Errorf ( "lambda %d: expected undefined, got %v" , i + 1 , v )
1848
+ var output interface {}
1849
+ if v . IsValid () && v . CanInterface () {
1850
+ output = v . Interface ( )
1846
1851
}
1847
- } else {
1848
- if ! reflect .DeepEqual (test .Output , output ) {
1849
- t .Errorf ("lambda %d: expected %v, got %v" , i + 1 , test .Output , output )
1852
+
1853
+ if test .Undefined {
1854
+ if v != undefined {
1855
+ t .Errorf ("lambda %d: expected undefined, got %v" , i + 1 , v )
1856
+ }
1857
+ } else {
1858
+ if ! reflect .DeepEqual (test .Output , output ) {
1859
+ t .Errorf ("lambda %d: expected %v, got %v" , i + 1 , test .Output , output )
1860
+ }
1850
1861
}
1851
- }
1852
1862
1853
- if ! reflect .DeepEqual (test .Error , err ) {
1854
- t .Errorf ("lambda %d: expected error %v, got %v" , i + 1 , test .Error , err )
1855
- }
1863
+ if ! reflect .DeepEqual (test .Error , err ) {
1864
+ t .Errorf ("lambda %d: expected error %v, got %v" , i + 1 , test .Error , err )
1865
+ }
1866
+ })
1856
1867
}
1857
1868
}
1858
1869
0 commit comments