Commit 46bce2ac authored by Rémy Oudompheng's avatar Rémy Oudompheng

test: convert more tests to rundir/compiledir conventions

Update #4139.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6609051
parent 5497787d
// 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() {
}
// $G $D/bug191.dir/a.go && $G $D/bug191.dir/b.go && $G $D/$F.go && $L $F.$A
// 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.
// rundircmpout
// 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
// Tests bug with dot imports.
func main() {
}
package ignored
// 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}
// $G $D/$F.dir/pkg.go && $G $D/$F.go || echo "Bug 382"
// 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.
// compiledir
// 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
// Issue 2529.
var fo = struct {F pkg.T}{F: x}
package ignored
// 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")
}
}
// $G $D/$F.dir/lib.go && $G $D/$F.go && $L $F.$A && ./$A.out
// 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.
// rundir
// Copyright 2012 The Go Authors. All rights reserved.
// 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
// 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")
}
package ignored
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")
}
}
// 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)
// $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.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
......
// skip # used by import3
// compiledir
// 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.
// Imported by import3.go.
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)
// Tests that export data does not corrupt type syntax.
package ignored
// 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 ( )
// 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"
// $G $D/empty.go && errchk $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.
// errorcheckdir
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......@@ -11,19 +8,4 @@
// 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"
package ignored
// skip
// 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.
// This file is not tested by itself; it is imported by method4.go.
package method4a
......
// 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)
}
// $G $D/method4a.go && $G $D/$F.go && $L $F.$A && ./$A.out
// 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.
// rundir
// 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)
}
package ignored
......@@ -639,11 +639,8 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
var skipOkay = map[string]bool{
"args.go": true,
"ddd3.go": true,
"import3.go": true,
"import4.go": true,
"index.go": true,
"linkx.go": true,
"method4.go": true,
"nul1.go": true,
"rotate.go": true,
"sigchld.go": true,
......@@ -672,16 +669,13 @@ var skipOkay = map[string]bool{
"dwarf/z7.go": true,
"dwarf/z8.go": true,
"dwarf/z9.go": true,
"fixedbugs/bug191.go": true,
"fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir.
"fixedbugs/bug302.go": true, // tests both .$O and .a imports.
"fixedbugs/bug313.go": true, // errorcheckdir with failures in the middle.
"fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation.
"fixedbugs/bug369.go": true,
"fixedbugs/bug382.go": true,
"fixedbugs/bug385_32.go": true,
"fixedbugs/bug385_64.go": true,
"fixedbugs/bug424.go": true,
"fixedbugs/bug369.go": true, // needs compiler flags.
"fixedbugs/bug385_32.go": true, // arch-specific errors.
"fixedbugs/bug385_64.go": true, // arch-specific errors.
"fixedbugs/bug429.go": true,
"fixedbugs/bug437.go": true,
"bugs/bug395.go": true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment