summaryrefslogtreecommitdiff
path: root/src/go/parser/parser_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/parser/parser_test.go')
-rw-r--r--src/go/parser/parser_test.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go
index 85065fd18..51ce1a933 100644
--- a/src/go/parser/parser_test.go
+++ b/src/go/parser/parser_test.go
@@ -14,8 +14,6 @@ import (
"testing"
)
-var fset = token.NewFileSet()
-
var validFiles = []string{
"parser.go",
"parser_test.go",
@@ -25,7 +23,7 @@ var validFiles = []string{
func TestParse(t *testing.T) {
for _, filename := range validFiles {
- _, err := ParseFile(fset, filename, nil, DeclarationErrors)
+ _, err := ParseFile(token.NewFileSet(), filename, nil, DeclarationErrors)
if err != nil {
t.Fatalf("ParseFile(%s): %v", filename, err)
}
@@ -46,7 +44,7 @@ func dirFilter(f os.FileInfo) bool { return nameFilter(f.Name()) }
func TestParseDir(t *testing.T) {
path := "."
- pkgs, err := ParseDir(fset, path, dirFilter, 0)
+ pkgs, err := ParseDir(token.NewFileSet(), path, dirFilter, 0)
if err != nil {
t.Fatalf("ParseDir(%s): %v", path, err)
}
@@ -131,7 +129,7 @@ func TestParseExpr(t *testing.T) {
}
func TestColonEqualsScope(t *testing.T) {
- f, err := ParseFile(fset, "", `package p; func f() { x, y, z := x, y, z }`, 0)
+ f, err := ParseFile(token.NewFileSet(), "", `package p; func f() { x, y, z := x, y, z }`, 0)
if err != nil {
t.Fatal(err)
}
@@ -153,7 +151,7 @@ func TestColonEqualsScope(t *testing.T) {
}
func TestVarScope(t *testing.T) {
- f, err := ParseFile(fset, "", `package p; func f() { var x, y, z = x, y, z }`, 0)
+ f, err := ParseFile(token.NewFileSet(), "", `package p; func f() { var x, y, z = x, y, z }`, 0)
if err != nil {
t.Fatal(err)
}
@@ -183,7 +181,7 @@ var x int
func f() { L: }
`
- f, err := ParseFile(fset, "", src, 0)
+ f, err := ParseFile(token.NewFileSet(), "", src, 0)
if err != nil {
t.Fatal(err)
}
@@ -221,7 +219,7 @@ func f() { L: }
}
func TestUnresolved(t *testing.T) {
- f, err := ParseFile(fset, "", `
+ f, err := ParseFile(token.NewFileSet(), "", `
package p
//
func f1a(int)
@@ -316,7 +314,7 @@ var imports = map[string]bool{
func TestImports(t *testing.T) {
for path, isValid := range imports {
src := fmt.Sprintf("package p; import %s", path)
- _, err := ParseFile(fset, "", src, 0)
+ _, err := ParseFile(token.NewFileSet(), "", src, 0)
switch {
case err != nil && isValid:
t.Errorf("ParseFile(%s): got %v; expected no error", src, err)
@@ -327,7 +325,7 @@ func TestImports(t *testing.T) {
}
func TestCommentGroups(t *testing.T) {
- f, err := ParseFile(fset, "", `
+ f, err := ParseFile(token.NewFileSet(), "", `
package p /* 1a */ /* 1b */ /* 1c */ // 1d
/* 2a
*/
@@ -421,7 +419,7 @@ func checkFieldComments(t *testing.T, file *ast.File, fieldname, lead, line stri
}
func TestLeadAndLineComments(t *testing.T) {
- f, err := ParseFile(fset, "", `
+ f, err := ParseFile(token.NewFileSet(), "", `
package p
type T struct {
/* F1 lead comment */