go.tools/ssa/interp: remove irrelevent parts of test, improve comments.
(Discovered during diagnosis of bug 7131.) R=gri CC=golang-codereviews https://golang.org/cl/52780043
This commit is contained in:
parent
5d7773006a
commit
8dabab4124
|
@ -2,8 +2,6 @@ package main
|
||||||
|
|
||||||
// Test of initialization order of package-level vars.
|
// Test of initialization order of package-level vars.
|
||||||
|
|
||||||
type T int
|
|
||||||
|
|
||||||
var counter int
|
var counter int
|
||||||
|
|
||||||
func next() int {
|
func next() int {
|
||||||
|
@ -12,17 +10,15 @@ func next() int {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (T) next() int {
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
var t T
|
|
||||||
|
|
||||||
func makeOrder1() [6]int {
|
func makeOrder1() [6]int {
|
||||||
|
// The values of these vars are determined by the (arbitrary)
|
||||||
|
// order in which we refer to them here. f=0, b=1, d=2, etc.
|
||||||
return [6]int{f1, b1, d1, e1, c1, a1}
|
return [6]int{f1, b1, d1, e1, c1, a1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeOrder2() [6]int {
|
func makeOrder2() [6]int {
|
||||||
|
// The values of these vars are independent of the order in
|
||||||
|
// which we refer to them here. a=6, b=7, c=8, etc.
|
||||||
return [6]int{f2, b2, d2, e2, c2, a2}
|
return [6]int{f2, b2, d2, e2, c2, a2}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +26,7 @@ var order1 = makeOrder1()
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// order1 is a package-level variable:
|
// order1 is a package-level variable:
|
||||||
// [a-f]1 are initialized is reference order.
|
// [a-f]1 are initialized in reference order.
|
||||||
if order1 != [6]int{0, 1, 2, 3, 4, 5} {
|
if order1 != [6]int{0, 1, 2, 3, 4, 5} {
|
||||||
panic(order1)
|
panic(order1)
|
||||||
}
|
}
|
||||||
|
@ -43,13 +39,10 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The references traversal visits through calls to package-level
|
|
||||||
// functions (next), method expressions (T.next) and methods (t.next).
|
|
||||||
|
|
||||||
var a1, b1 = next(), next()
|
var a1, b1 = next(), next()
|
||||||
var c1, d1 = T.next(0), T.next(0)
|
var c1, d1 = next(), next()
|
||||||
var e1, f1 = t.next(), t.next()
|
var e1, f1 = next(), next()
|
||||||
|
|
||||||
var a2, b2 = next(), next()
|
var a2, b2 = next(), next()
|
||||||
var c2, d2 = T.next(0), T.next(0)
|
var c2, d2 = next(), next()
|
||||||
var e2, f2 = t.next(), t.next()
|
var e2, f2 = next(), next()
|
||||||
|
|
Loading…
Reference in New Issue