go/types: remove global vars in test

Change-Id: I5fb61a38362a40c706ba5cb8968c387c8dc4aef2
Reviewed-on: https://go-review.googlesource.com/10992
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-06-12 14:15:51 -07:00
parent 665374f1c8
commit 568df9f49c
1 changed files with 72 additions and 72 deletions

View File

@ -16,81 +16,81 @@ import (
. "golang.org/x/tools/go/types"
)
var sources = []string{
`
package p
import "fmt"
import "math"
const pi = math.Pi
func sin(x float64) float64 {
return math.Sin(x)
}
var Println = fmt.Println
`,
`
package p
import "fmt"
type errorStringer struct { fmt.Stringer; error }
func f() string {
_ = "foo"
return fmt.Sprintf("%d", g())
}
func g() (x int) { return }
`,
`
package p
import . "go/parser"
import "sync"
func h() Mode { return ImportsOnly }
var _, x int = 1, 2
func init() {}
type T struct{ *sync.Mutex; a, b, c int}
type I interface{ m() }
var _ = T{a: 1, b: 2, c: 3}
func (_ T) m() {}
func (T) _() {}
var i I
var _ = i.m
func _(s []int) { for i, x := range s { _, _ = i, x } }
func _(x interface{}) {
switch x := x.(type) {
case int:
_ = x
}
switch {} // implicit 'true' tag
}
`,
`
package p
type S struct{}
func (T) _() {}
func (T) _() {}
`,
`
package p
func _() {
L0:
L1:
goto L0
for {
goto L1
}
if true {
goto L2
}
L2:
}
`,
}
var pkgnames = []string{
"fmt",
"math",
}
func TestResolveIdents(t *testing.T) {
skipSpecialPlatforms(t)
sources := []string{
`
package p
import "fmt"
import "math"
const pi = math.Pi
func sin(x float64) float64 {
return math.Sin(x)
}
var Println = fmt.Println
`,
`
package p
import "fmt"
type errorStringer struct { fmt.Stringer; error }
func f() string {
_ = "foo"
return fmt.Sprintf("%d", g())
}
func g() (x int) { return }
`,
`
package p
import . "go/parser"
import "sync"
func h() Mode { return ImportsOnly }
var _, x int = 1, 2
func init() {}
type T struct{ *sync.Mutex; a, b, c int}
type I interface{ m() }
var _ = T{a: 1, b: 2, c: 3}
func (_ T) m() {}
func (T) _() {}
var i I
var _ = i.m
func _(s []int) { for i, x := range s { _, _ = i, x } }
func _(x interface{}) {
switch x := x.(type) {
case int:
_ = x
}
switch {} // implicit 'true' tag
}
`,
`
package p
type S struct{}
func (T) _() {}
func (T) _() {}
`,
`
package p
func _() {
L0:
L1:
goto L0
for {
goto L1
}
if true {
goto L2
}
L2:
}
`,
}
pkgnames := []string{
"fmt",
"math",
}
// parse package files
fset := token.NewFileSet()
var files []*ast.File