1
0
mirror of https://github.com/golang/go synced 2024-11-14 06:20:23 -07:00

test: convert more tests to rundir/compiledir conventions

Update #4139.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6609051
This commit is contained in:
Rémy Oudompheng 2012-10-07 23:22:01 +02:00
parent 5497787d35
commit 46bce2ac27
17 changed files with 324 additions and 295 deletions

View File

@ -0,0 +1,14 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import . "./a"
import . "./b"
var _ T
var _ V
func main() {
}

View File

@ -1,19 +1,9 @@
// $G $D/bug191.dir/a.go && $G $D/bug191.dir/b.go && $G $D/$F.go && $L $F.$A // rundircmpout
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package main // Tests bug with dot imports.
import . "./a" package ignored
import . "./b"
var _ T
var _ V
func main() {
}

View File

@ -0,0 +1,2 @@
b
a

View File

@ -0,0 +1,13 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file
// Issue 2529
package main
import "./pkg"
var x = pkg.E
var fo = struct{ F pkg.T }{F: x}

View File

@ -1,17 +1,9 @@
// $G $D/$F.dir/pkg.go && $G $D/$F.go || echo "Bug 382" // compiledir
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2011 The Go Authors. All rights reserved. // Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file // license that can be found in the LICENSE file
// Issue 2529 // Issue 2529.
package main package ignored
import "./pkg"
var x = pkg.E
var fo = struct {F pkg.T}{F: x}

View File

@ -0,0 +1,97 @@
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Tests that method calls through an interface always
// call the locally defined method localT.m independent
// at which embedding level it is and in which order
// embedding is done.
package main
import "./lib"
import "reflect"
import "fmt"
type localI interface {
m() string
}
type localT struct{}
func (t *localT) m() string {
return "main.localT.m"
}
type myT1 struct {
localT
}
type myT2 struct {
localT
lib.T
}
type myT3 struct {
lib.T
localT
}
func main() {
var i localI
i = new(localT)
if i.m() != "main.localT.m" {
println("BUG: localT:", i.m(), "called")
}
i = new(myT1)
if i.m() != "main.localT.m" {
println("BUG: myT1:", i.m(), "called")
}
i = new(myT2)
if i.m() != "main.localT.m" {
println("BUG: myT2:", i.m(), "called")
}
t3 := new(myT3)
if t3.m() != "main.localT.m" {
println("BUG: t3:", t3.m(), "called")
}
i = new(myT3)
if i.m() != "main.localT.m" {
t := reflect.TypeOf(i)
n := t.NumMethod()
for j := 0; j < n; j++ {
m := t.Method(j)
fmt.Printf("#%d: %s.%s %s\n", j, m.PkgPath, m.Name, m.Type)
}
println("BUG: myT3:", i.m(), "called")
}
var t4 struct {
localT
lib.T
}
if t4.m() != "main.localT.m" {
println("BUG: t4:", t4.m(), "called")
}
i = &t4
if i.m() != "main.localT.m" {
println("BUG: myT4:", i.m(), "called")
}
var t5 struct {
lib.T
localT
}
if t5.m() != "main.localT.m" {
println("BUG: t5:", t5.m(), "called")
}
i = &t5
if i.m() != "main.localT.m" {
println("BUG: myT5:", i.m(), "called")
}
}

View File

@ -1,7 +1,4 @@
// $G $D/$F.dir/lib.go && $G $D/$F.go && $L $F.$A && ./$A.out // rundir
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
@ -12,91 +9,5 @@
// at which embedding level it is and in which order // at which embedding level it is and in which order
// embedding is done. // embedding is done.
package main package ignored
import "./lib"
import "reflect"
import "fmt"
type localI interface {
m() string
}
type localT struct{}
func (t *localT) m() string {
return "main.localT.m"
}
type myT1 struct {
localT
}
type myT2 struct {
localT
lib.T
}
type myT3 struct {
lib.T
localT
}
func main() {
var i localI
i = new(localT)
if i.m() != "main.localT.m" {
println("BUG: localT:", i.m(), "called")
}
i = new(myT1)
if i.m() != "main.localT.m" {
println("BUG: myT1:", i.m(), "called")
}
i = new(myT2)
if i.m() != "main.localT.m" {
println("BUG: myT2:", i.m(), "called")
}
t3 := new(myT3)
if t3.m() != "main.localT.m" {
println("BUG: t3:", t3.m(), "called")
}
i = new(myT3)
if i.m() != "main.localT.m" {
t := reflect.TypeOf(i)
n := t.NumMethod()
for j := 0; j < n; j++ {
m := t.Method(j)
fmt.Printf("#%d: %s.%s %s\n", j, m.PkgPath, m.Name, m.Type)
}
println("BUG: myT3:", i.m(), "called")
}
var t4 struct {
localT
lib.T
}
if t4.m() != "main.localT.m" {
println("BUG: t4:", t4.m(), "called")
}
i = &t4
if i.m() != "main.localT.m" {
println("BUG: myT4:", i.m(), "called")
}
var t5 struct {
lib.T
localT
}
if t5.m() != "main.localT.m" {
println("BUG: t5:", t5.m(), "called")
}
i = &t5
if i.m() != "main.localT.m" {
println("BUG: myT5:", i.m(), "called")
}
}

View File

@ -0,0 +1,42 @@
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Various declarations of exported variables and functions.
package p
var C1 chan <- chan int = (chan<- (chan int))(nil)
var C2 chan (<- chan int) = (chan (<-chan int))(nil)
var C3 <- chan chan int = (<-chan (chan int))(nil)
var C4 chan chan <- int = (chan (chan<- int))(nil)
var C5 <- chan <- chan int = (<-chan (<-chan int))(nil)
var C6 chan <- <- chan int = (chan<- (<-chan int))(nil)
var C7 chan <- chan <- int = (chan<- (chan<- int))(nil)
var C8 <- chan <- chan chan int = (<-chan (<-chan (chan int)))(nil)
var C9 <- chan chan <- chan int = (<-chan (chan<- (chan int)))(nil)
var C10 chan <- <- chan chan int = (chan<- (<-chan (chan int)))(nil)
var C11 chan <- chan <- chan int = (chan<- (chan<- (chan int)))(nil)
var C12 chan chan <- <- chan int = (chan (chan<- (<-chan int)))(nil)
var C13 chan chan <- chan <- int = (chan (chan<- (chan<- int)))(nil)
var R1 chan<- (chan int) = (chan <- chan int)(nil)
var R3 <-chan (chan int) = (<- chan chan int)(nil)
var R4 chan (chan<- int) = (chan chan <- int)(nil)
var R5 <-chan (<-chan int) = (<- chan <- chan int)(nil)
var R6 chan<- (<-chan int) = (chan <- <- chan int)(nil)
var R7 chan<- (chan<- int) = (chan <- chan <- int)(nil)
var R8 <-chan (<-chan (chan int)) = (<- chan <- chan chan int)(nil)
var R9 <-chan (chan<- (chan int)) = (<- chan chan <- chan int)(nil)
var R10 chan<- (<-chan (chan int)) = (chan <- <- chan chan int)(nil)
var R11 chan<- (chan<- (chan int)) = (chan <- chan <- chan int)(nil)
var R12 chan (chan<- (<-chan int)) = (chan chan <- <- chan int)(nil)
var R13 chan (chan<- (chan<- int)) = (chan chan <- chan <- int)(nil)
var F1 func() func() int
func F2() func() func() int
func F3(func() func() int)

View File

@ -1,8 +1,3 @@
// $G $D/import2.go && $G $D/$F.go
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2010 The Go Authors. All rights reserved. // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,45 +1,8 @@
// skip # used by import3 // compiledir
// Copyright 2010 The Go Authors. All rights reserved. // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Various declarations of exported variables and functions. // Tests that export data does not corrupt type syntax.
// Imported by import3.go. package ignored
package p
var C1 chan <- chan int = (chan<- (chan int))(nil)
var C2 chan (<- chan int) = (chan (<-chan int))(nil)
var C3 <- chan chan int = (<-chan (chan int))(nil)
var C4 chan chan <- int = (chan (chan<- int))(nil)
var C5 <- chan <- chan int = (<-chan (<-chan int))(nil)
var C6 chan <- <- chan int = (chan<- (<-chan int))(nil)
var C7 chan <- chan <- int = (chan<- (chan<- int))(nil)
var C8 <- chan <- chan chan int = (<-chan (<-chan (chan int)))(nil)
var C9 <- chan chan <- chan int = (<-chan (chan<- (chan int)))(nil)
var C10 chan <- <- chan chan int = (chan<- (<-chan (chan int)))(nil)
var C11 chan <- chan <- chan int = (chan<- (chan<- (chan int)))(nil)
var C12 chan chan <- <- chan int = (chan (chan<- (<-chan int)))(nil)
var C13 chan chan <- chan <- int = (chan (chan<- (chan<- int)))(nil)
var R1 chan<- (chan int) = (chan <- chan int)(nil)
var R3 <-chan (chan int) = (<- chan chan int)(nil)
var R4 chan (chan<- int) = (chan chan <- int)(nil)
var R5 <-chan (<-chan int) = (<- chan <- chan int)(nil)
var R6 chan<- (<-chan int) = (chan <- <- chan int)(nil)
var R7 chan<- (chan<- int) = (chan <- chan <- int)(nil)
var R8 <-chan (<-chan (chan int)) = (<- chan <- chan chan int)(nil)
var R9 <-chan (chan<- (chan int)) = (<- chan chan <- chan int)(nil)
var R10 chan<- (<-chan (chan int)) = (chan <- <- chan chan int)(nil)
var R11 chan<- (chan<- (chan int)) = (chan <- chan <- chan int)(nil)
var R12 chan (chan<- (<-chan int)) = (chan chan <- <- chan int)(nil)
var R13 chan (chan<- (chan<- int)) = (chan chan <- chan <- int)(nil)
var F1 func() func() int
func F2() func() func() int
func F3(func() func() int)

10
test/import4.dir/empty.go Normal file
View File

@ -0,0 +1,10 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package P
import ( )
const ( )
var ( )
type ( )

View File

@ -0,0 +1,24 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Verify that various kinds of "imported and not used"
// errors are caught by the compiler.
// Does not compile.
package main
// standard
import "fmt" // ERROR "imported and not used.*fmt"
// renamed
import X "math" // ERROR "imported and not used.*math"
// import dot
import . "bufio" // ERROR "imported and not used.*bufio"
// again, package without anything in it
import "./empty" // ERROR "imported and not used.*empty"
import Z "./empty" // ERROR "imported and not used.*empty"
import . "./empty" // ERROR "imported and not used.*empty"

View File

@ -1,7 +1,4 @@
// $G $D/empty.go && errchk $G $D/$F.go // errorcheckdir
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
@ -11,19 +8,4 @@
// errors are caught by the compiler. // errors are caught by the compiler.
// Does not compile. // Does not compile.
package main package ignored
// standard
import "fmt" // ERROR "imported and not used.*fmt"
// renamed
import X "math" // ERROR "imported and not used.*math"
// import dot
import . "bufio" // ERROR "imported and not used.*bufio"
// again, package without anything in it
import "./empty" // ERROR "imported and not used.*empty"
import Z "./empty" // ERROR "imported and not used.*empty"
import . "./empty" // ERROR "imported and not used.*empty"

View File

@ -1,11 +1,8 @@
// skip
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Test method expressions with arguments. // Test method expressions with arguments.
// This file is not tested by itself; it is imported by method4.go.
package method4a package method4a

104
test/method4.dir/prog.go Normal file
View File

@ -0,0 +1,104 @@
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test method expressions with arguments.
package main
import "./method4a"
type T1 int
type T2 struct {
f int
}
type I1 interface {
Sum([]int, int) int
}
type I2 interface {
Sum(a []int, b int) int
}
func (i T1) Sum(a []int, b int) int {
r := int(i) + b
for _, v := range a {
r += v
}
return r
}
func (p *T2) Sum(a []int, b int) int {
r := p.f + b
for _, v := range a {
r += v
}
return r
}
func eq(v1, v2 int) {
if v1 != v2 {
panic(0)
}
}
func main() {
a := []int{1, 2, 3}
t1 := T1(4)
t2 := &T2{4}
eq(t1.Sum(a, 5), 15)
eq(t2.Sum(a, 6), 16)
eq(T1.Sum(t1, a, 7), 17)
eq((*T2).Sum(t2, a, 8), 18)
f1 := T1.Sum
eq(f1(t1, a, 9), 19)
f2 := (*T2).Sum
eq(f2(t2, a, 10), 20)
eq(I1.Sum(t1, a, 11), 21)
eq(I1.Sum(t2, a, 12), 22)
f3 := I1.Sum
eq(f3(t1, a, 13), 23)
eq(f3(t2, a, 14), 24)
eq(I2.Sum(t1, a, 15), 25)
eq(I2.Sum(t2, a, 16), 26)
f4 := I2.Sum
eq(f4(t1, a, 17), 27)
eq(f4(t2, a, 18), 28)
mt1 := method4a.T1(4)
mt2 := &method4a.T2{4}
eq(mt1.Sum(a, 30), 40)
eq(mt2.Sum(a, 31), 41)
eq(method4a.T1.Sum(mt1, a, 32), 42)
eq((*method4a.T2).Sum(mt2, a, 33), 43)
g1 := method4a.T1.Sum
eq(g1(mt1, a, 34), 44)
g2 := (*method4a.T2).Sum
eq(g2(mt2, a, 35), 45)
eq(method4a.I1.Sum(mt1, a, 36), 46)
eq(method4a.I1.Sum(mt2, a, 37), 47)
g3 := method4a.I1.Sum
eq(g3(mt1, a, 38), 48)
eq(g3(mt2, a, 39), 49)
eq(method4a.I2.Sum(mt1, a, 40), 50)
eq(method4a.I2.Sum(mt2, a, 41), 51)
g4 := method4a.I2.Sum
eq(g4(mt1, a, 42), 52)
eq(g4(mt2, a, 43), 53)
}

View File

@ -1,109 +1,8 @@
// $G $D/method4a.go && $G $D/$F.go && $L $F.$A && ./$A.out // rundir
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Test method expressions with arguments. // Test method expressions with arguments.
package ignored
package main
import "./method4a"
type T1 int
type T2 struct {
f int
}
type I1 interface {
Sum([]int, int) int
}
type I2 interface {
Sum(a []int, b int) int
}
func (i T1) Sum(a []int, b int) int {
r := int(i) + b
for _, v := range a {
r += v
}
return r
}
func (p *T2) Sum(a []int, b int) int {
r := p.f + b
for _, v := range a {
r += v
}
return r
}
func eq(v1, v2 int) {
if v1 != v2 {
panic(0)
}
}
func main() {
a := []int{1, 2, 3}
t1 := T1(4)
t2 := &T2{4}
eq(t1.Sum(a, 5), 15)
eq(t2.Sum(a, 6), 16)
eq(T1.Sum(t1, a, 7), 17)
eq((*T2).Sum(t2, a, 8), 18)
f1 := T1.Sum
eq(f1(t1, a, 9), 19)
f2 := (*T2).Sum
eq(f2(t2, a, 10), 20)
eq(I1.Sum(t1, a, 11), 21)
eq(I1.Sum(t2, a, 12), 22)
f3 := I1.Sum
eq(f3(t1, a, 13), 23)
eq(f3(t2, a, 14), 24)
eq(I2.Sum(t1, a, 15), 25)
eq(I2.Sum(t2, a, 16), 26)
f4 := I2.Sum
eq(f4(t1, a, 17), 27)
eq(f4(t2, a, 18), 28)
mt1 := method4a.T1(4)
mt2 := &method4a.T2{4}
eq(mt1.Sum(a, 30), 40)
eq(mt2.Sum(a, 31), 41)
eq(method4a.T1.Sum(mt1, a, 32), 42)
eq((*method4a.T2).Sum(mt2, a, 33), 43)
g1 := method4a.T1.Sum
eq(g1(mt1, a, 34), 44)
g2 := (*method4a.T2).Sum
eq(g2(mt2, a, 35), 45)
eq(method4a.I1.Sum(mt1, a, 36), 46)
eq(method4a.I1.Sum(mt2, a, 37), 47)
g3 := method4a.I1.Sum
eq(g3(mt1, a, 38), 48)
eq(g3(mt2, a, 39), 49)
eq(method4a.I2.Sum(mt1, a, 40), 50)
eq(method4a.I2.Sum(mt2, a, 41), 51)
g4 := method4a.I2.Sum
eq(g4(mt1, a, 42), 52)
eq(g4(mt2, a, 43), 53)
}

View File

@ -639,11 +639,8 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
var skipOkay = map[string]bool{ var skipOkay = map[string]bool{
"args.go": true, "args.go": true,
"ddd3.go": true, "ddd3.go": true,
"import3.go": true,
"import4.go": true,
"index.go": true, "index.go": true,
"linkx.go": true, "linkx.go": true,
"method4.go": true,
"nul1.go": true, "nul1.go": true,
"rotate.go": true, "rotate.go": true,
"sigchld.go": true, "sigchld.go": true,
@ -672,16 +669,13 @@ var skipOkay = map[string]bool{
"dwarf/z7.go": true, "dwarf/z7.go": true,
"dwarf/z8.go": true, "dwarf/z8.go": true,
"dwarf/z9.go": true, "dwarf/z9.go": true,
"fixedbugs/bug191.go": true,
"fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir. "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir.
"fixedbugs/bug302.go": true, // tests both .$O and .a imports. "fixedbugs/bug302.go": true, // tests both .$O and .a imports.
"fixedbugs/bug313.go": true, // errorcheckdir with failures in the middle. "fixedbugs/bug313.go": true, // errorcheckdir with failures in the middle.
"fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation. "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation.
"fixedbugs/bug369.go": true, "fixedbugs/bug369.go": true, // needs compiler flags.
"fixedbugs/bug382.go": true, "fixedbugs/bug385_32.go": true, // arch-specific errors.
"fixedbugs/bug385_32.go": true, "fixedbugs/bug385_64.go": true, // arch-specific errors.
"fixedbugs/bug385_64.go": true,
"fixedbugs/bug424.go": true,
"fixedbugs/bug429.go": true, "fixedbugs/bug429.go": true,
"fixedbugs/bug437.go": true, "fixedbugs/bug437.go": true,
"bugs/bug395.go": true, "bugs/bug395.go": true,