diff options
Diffstat (limited to 'parser/interpreter_test.go')
| -rw-r--r-- | parser/interpreter_test.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/parser/interpreter_test.go b/parser/interpreter_test.go index df44fae..a459359 100644 --- a/parser/interpreter_test.go +++ b/parser/interpreter_test.go @@ -211,7 +211,7 @@ func TestStruct(t *testing.T) { } func TestType(t *testing.T) { - src0 := `type( + src0 := `type ( I int S string ) @@ -239,3 +239,19 @@ func TestVar(t *testing.T) { ); a+b+c`, res: "16"}, }) } + +func TestImport(t *testing.T) { + src0 := `import ( + "fmt" +) +` + run(t, []etest{ + {src: "fmt.Println(4)", err: "symbol not found: fmt"}, + {src: `import "xxx"`, err: "package not found: xxx"}, + {src: `import "fmt"; fmt.Println(4)`, res: "<nil>"}, + {src: src0 + "fmt.Println(4)", res: "<nil>"}, + {src: `func main() {import "fmt"; fmt.Println("hello")}`, err: "unexpected import"}, + {src: `import m "fmt"; m.Println(4)`, res: "<nil>"}, + {src: `import . "fmt"; Println(4)`, res: "<nil>"}, + }) +} |
