@@ -22,6 +22,21 @@ func cleanup(value string) string {
2222 return result
2323}
2424
25+ func makeIdents (name string , line , col int ) []* parser.Ident {
26+ return []* parser.Ident {{
27+ Pos : makePos (line , col ),
28+ Name : name ,
29+ }}
30+ }
31+
32+ func makePos (line , col int ) lexer.Position {
33+ return lexer.Position {
34+ Filename : "<stdin>" ,
35+ Line : line ,
36+ Column : col ,
37+ }
38+ }
39+
2540func TestChecker_Check (t * testing.T ) {
2641 t .Parallel ()
2742
@@ -308,7 +323,11 @@ func TestChecker_Check(t *testing.T) {
308323 run "echo hi" with opts
309324 }
310325 ` ,
311- ErrWrongArgType {},
326+ ErrWrongArgType {
327+ Pos : makePos (2 , 8 ),
328+ Expected : "option::run" ,
329+ Found : "string" ,
330+ },
312331 }, /*{
313332 "variadic options with bad method type",
314333 `
@@ -335,7 +354,11 @@ func TestChecker_Check(t *testing.T) {
335354 run "echo hi" with opts
336355 }
337356 ` ,
338- ErrWrongArgType {},
357+ ErrWrongArgType {
358+ Pos : makePos (2 , 23 ),
359+ Expected : "option::run" ,
360+ Found : "string" ,
361+ },
339362 }, {
340363 "func call with bad arg count" ,
341364 `
@@ -347,7 +370,13 @@ func TestChecker_Check(t *testing.T) {
347370 run cmd
348371 }
349372 ` ,
350- ErrNumArgs {},
373+ ErrNumArgs {
374+ Expected : 1 ,
375+ CallStmt : & parser.CallStmt {
376+ Pos : makePos (2 , 1 ),
377+ Args : make ([]* parser.Expr , 2 ),
378+ },
379+ },
351380 }, {
352381 "func call with bad arg type: basic literal" ,
353382 `
@@ -359,7 +388,11 @@ func TestChecker_Check(t *testing.T) {
359388 run cmd
360389 }
361390 ` ,
362- ErrWrongArgType {},
391+ ErrWrongArgType {
392+ Pos : makePos (2 , 8 ),
393+ Expected : "string" ,
394+ Found : "int" ,
395+ },
363396 }, /*{
364397 "func call with bad arg type: basic ident",
365398 `
@@ -394,7 +427,11 @@ func TestChecker_Check(t *testing.T) {
394427 run cmd
395428 }
396429 ` ,
397- ErrWrongArgType {},
430+ ErrWrongArgType {
431+ Pos : makePos (2 , 8 ),
432+ Expected : "string" ,
433+ Found : "fs" ,
434+ },
398435 }, {
399436 "func call with bad subtype" ,
400437 `
@@ -407,7 +444,11 @@ func TestChecker_Check(t *testing.T) {
407444 run cmd
408445 }
409446 ` ,
410- ErrWrongArgType {},
447+ ErrWrongArgType {
448+ Pos : makePos (2 , 1 ),
449+ Expected : "fs" ,
450+ Found : "option::run" ,
451+ },
411452 }, /*{
412453 "func call with bad option type",
413454 `
@@ -499,7 +540,6 @@ func TestChecker_Check(t *testing.T) {
499540 }
500541}
501542
502-
503543func TestChecker_CheckSelectors (t * testing.T ) {
504544 t .Parallel ()
505545
@@ -572,7 +612,7 @@ func validateError(t *testing.T, expectedError error, actualError error) {
572612 // assume if we got a semantic error we really want
573613 // to validate the underlying error
574614 if semErr , ok := actualError .(ErrSemantic ); ok {
575- require .IsType (t , expectedError , semErr .Errs [0 ])
615+ require .IsType (t , expectedError , semErr .Errs [0 ], "type %T" , semErr . Errs [ 0 ] )
576616 require .Equal (t , expectedError .Error (), semErr .Errs [0 ].Error (), "error: %v" , actualError )
577617 } else {
578618 require .IsType (t , expectedError , actualError , "error: %v" , actualError )
0 commit comments