Skip to content

Commit

Permalink
Make result tests more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jun 13, 2021
1 parent a1a531d commit b223e48
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions interp/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ type resultTestCase struct {
}

func TestEvalFileResult(t *testing.T) {
type Results = []interp.FileStatementResult
type Import = interp.PackageImportResult
type Func = interp.FunctionDeclarationResult
type Type = interp.TypeDeclarationResult

i := interp.New(interp.Options{})
i.Use(stdlib.Symbols)
runResultTests(t, i, []resultTestCase{
{desc: "bare import", src: `import "time"`, res: &interp.PackageImportResult{Path: "time"}},
{desc: "named import", src: `import x "time"`, res: &interp.PackageImportResult{Name: "x", Path: "time"}},
{desc: "multiple imports", src: "import (\ny \"time\"\nz \"fmt\"\n)", res: []interp.FileStatementResult{&interp.PackageImportResult{Name: "y", Path: "time"}, &interp.PackageImportResult{Name: "z", Path: "fmt"}}},
{desc: "bare import", src: `import "time"`, res: &Import{Path: "time"}},
{desc: "named import", src: `import x "time"`, res: &Import{Name: "x", Path: "time"}},
{desc: "multiple imports", src: "import (\ny \"time\"\nz \"fmt\"\n)", res: Results{&Import{Name: "y", Path: "time"}, &Import{Name: "z", Path: "fmt"}}},

{desc: "func", src: `func foo() {}`, res: &interp.FunctionDeclarationResult{Name: "foo"}},
{desc: "func", src: `func foo() { }`, res: &Func{Name: "foo"}},

{desc: "struct type", src: `type Foo struct {}`, res: &interp.TypeDeclarationResult{Name: "Foo"}},
{desc: "struct type", src: `type Foo struct {}`, res: &Type{Name: "Foo"}},
})
}

Expand Down

0 comments on commit b223e48

Please sign in to comment.