diff --git a/test/fixedbugs/bug191.dir/main.go b/test/fixedbugs/bug191.dir/main.go new file mode 100644 index 0000000000..995134ccfc --- /dev/null +++ b/test/fixedbugs/bug191.dir/main.go @@ -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() { +} diff --git a/test/fixedbugs/bug191.go b/test/fixedbugs/bug191.go index 11a6e58e51..acb4796b33 100644 --- a/test/fixedbugs/bug191.go +++ b/test/fixedbugs/bug191.go @@ -1,19 +1,9 @@ -// $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 +// Tests bug with dot imports. -import . "./a" -import . "./b" - -var _ T -var _ V - -func main() { -} +package ignored diff --git a/test/fixedbugs/bug191.out b/test/fixedbugs/bug191.out new file mode 100644 index 0000000000..0e1677a978 --- /dev/null +++ b/test/fixedbugs/bug191.out @@ -0,0 +1,2 @@ +b +a diff --git a/test/fixedbugs/bug382.dir/prog.go b/test/fixedbugs/bug382.dir/prog.go new file mode 100644 index 0000000000..b74a82d824 --- /dev/null +++ b/test/fixedbugs/bug382.dir/prog.go @@ -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} diff --git a/test/fixedbugs/bug382.go b/test/fixedbugs/bug382.go index 10c71d4662..6039939eeb 100644 --- a/test/fixedbugs/bug382.go +++ b/test/fixedbugs/bug382.go @@ -1,17 +1,9 @@ -// $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 +// Issue 2529. -package main -import "./pkg" - -var x = pkg.E - -var fo = struct {F pkg.T}{F: x} +package ignored diff --git a/test/fixedbugs/bug424.dir/main.go b/test/fixedbugs/bug424.dir/main.go new file mode 100644 index 0000000000..c2fe1463cd --- /dev/null +++ b/test/fixedbugs/bug424.dir/main.go @@ -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") + } +} diff --git a/test/fixedbugs/bug424.go b/test/fixedbugs/bug424.go index 41524543a8..59c2cd35c4 100644 --- a/test/fixedbugs/bug424.go +++ b/test/fixedbugs/bug424.go @@ -1,7 +1,4 @@ -// $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 +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") - } -} diff --git a/test/import2.dir/import2.go b/test/import2.dir/import2.go new file mode 100644 index 0000000000..8bb1eb9191 --- /dev/null +++ b/test/import2.dir/import2.go @@ -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) diff --git a/test/import3.go b/test/import2.dir/import3.go similarity index 89% rename from test/import3.go rename to test/import2.dir/import3.go index 0a5ba1d01a..d7fe37b199 100644 --- a/test/import3.go +++ b/test/import2.dir/import3.go @@ -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. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/test/import2.go b/test/import2.go index 5c275f34b3..f8d0b0a0fd 100644 --- a/test/import2.go +++ b/test/import2.go @@ -1,45 +1,8 @@ -// 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 diff --git a/test/import4.dir/empty.go b/test/import4.dir/empty.go new file mode 100644 index 0000000000..c8214f36da --- /dev/null +++ b/test/import4.dir/empty.go @@ -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 ( ) diff --git a/test/import4.dir/import4.go b/test/import4.dir/import4.go new file mode 100644 index 0000000000..b9f973f172 --- /dev/null +++ b/test/import4.dir/import4.go @@ -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" + diff --git a/test/import4.go b/test/import4.go index f35f567818..875bf89430 100644 --- a/test/import4.go +++ b/test/import4.go @@ -1,7 +1,4 @@ -// $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 diff --git a/test/method4a.go b/test/method4.dir/method4a.go similarity index 87% rename from test/method4a.go rename to test/method4.dir/method4a.go index d23039bfaa..a7df04cec3 100644 --- a/test/method4a.go +++ b/test/method4.dir/method4a.go @@ -1,11 +1,8 @@ -// 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 diff --git a/test/method4.dir/prog.go b/test/method4.dir/prog.go new file mode 100644 index 0000000000..77d580cffc --- /dev/null +++ b/test/method4.dir/prog.go @@ -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) +} diff --git a/test/method4.go b/test/method4.go index 7e7b1ff3b9..813892bc83 100644 --- a/test/method4.go +++ b/test/method4.go @@ -1,109 +1,8 @@ -// $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 diff --git a/test/run.go b/test/run.go index a6464e3802..b6437ee1d3 100644 --- a/test/run.go +++ b/test/run.go @@ -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,