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:
parent
665374f1c8
commit
568df9f49c
|
@ -16,81 +16,81 @@ import (
|
||||||
. "golang.org/x/tools/go/types"
|
. "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) {
|
func TestResolveIdents(t *testing.T) {
|
||||||
skipSpecialPlatforms(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
|
// parse package files
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
var files []*ast.File
|
var files []*ast.File
|
||||||
|
|
Loading…
Reference in New Issue