From dda1b560ec03e3c5da82bef67322f6f4d16cd7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Oudompheng?= Date: Wed, 10 Oct 2012 22:35:27 +0200 Subject: test: convert tests to run.go whenever possible. The other tests either need a complex procedure or are architecture- or OS-dependent. Update #4139. R=golang-dev, daniel.morsing, iant CC=golang-dev https://golang.org/cl/6618062 --- test/interface/embed0.go | 29 ------------------- test/interface/embed1.dir/embed0.go | 27 ++++++++++++++++++ test/interface/embed1.dir/embed1.go | 43 +++++++++++++++++++++++++++++ test/interface/embed1.go | 43 ++--------------------------- test/interface/private.dir/private1.go | 18 ++++++++++++ test/interface/private.dir/prog.go | 33 ++++++++++++++++++++++ test/interface/private.go | 32 ++------------------- test/interface/private1.go | 20 -------------- test/interface/recursive1.dir/recursive1.go | 15 ++++++++++ test/interface/recursive1.dir/recursive2.go | 20 ++++++++++++++ test/interface/recursive1.go | 12 ++------ test/interface/recursive2.go | 25 ----------------- 12 files changed, 162 insertions(+), 155 deletions(-) delete mode 100644 test/interface/embed0.go create mode 100644 test/interface/embed1.dir/embed0.go create mode 100644 test/interface/embed1.dir/embed1.go create mode 100644 test/interface/private.dir/private1.go create mode 100644 test/interface/private.dir/prog.go delete mode 100644 test/interface/private1.go create mode 100644 test/interface/recursive1.dir/recursive1.go create mode 100644 test/interface/recursive1.dir/recursive2.go delete mode 100644 test/interface/recursive2.go (limited to 'test/interface') diff --git a/test/interface/embed0.go b/test/interface/embed0.go deleted file mode 100644 index e2ee20adeb..0000000000 --- a/test/interface/embed0.go +++ /dev/null @@ -1,29 +0,0 @@ -// skip # used by embed1.go - -// 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. - -// Test that embedded interface types can have local methods. - -package p - -type T int -func (t T) m() {} - -type I interface { m() } -type J interface { I } - -func main() { - var i I - var j J - var t T - i = t - j = t - _ = i - _ = j - i = j - _ = i - j = i - _ = j -} diff --git a/test/interface/embed1.dir/embed0.go b/test/interface/embed1.dir/embed0.go new file mode 100644 index 0000000000..728bec74e8 --- /dev/null +++ b/test/interface/embed1.dir/embed0.go @@ -0,0 +1,27 @@ +// 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. + +// Test that embedded interface types can have local methods. + +package p + +type T int +func (t T) m() {} + +type I interface { m() } +type J interface { I } + +func main() { + var i I + var j J + var t T + i = t + j = t + _ = i + _ = j + i = j + _ = i + j = i + _ = j +} diff --git a/test/interface/embed1.dir/embed1.go b/test/interface/embed1.dir/embed1.go new file mode 100644 index 0000000000..7dfb1dbc0a --- /dev/null +++ b/test/interface/embed1.dir/embed1.go @@ -0,0 +1,43 @@ +// 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. + +// Test that embedded interface types can have local methods. + +package main + +import "./embed0" + +type T int +func (t T) m() {} + +type I interface { m() } +type J interface { I } + +type PI interface { p.I } +type PJ interface { p.J } + +func main() { + var i I + var j J + var t T + i = t + j = t + _ = i + _ = j + i = j + _ = i + j = i + _ = j + var pi PI + var pj PJ + var pt p.T + pi = pt + pj = pt + _ = pi + _ = pj + pi = pj + _ = pi + pj = pi + _ = pj +} diff --git a/test/interface/embed1.go b/test/interface/embed1.go index 07b873a633..784b82bb07 100644 --- a/test/interface/embed1.go +++ b/test/interface/embed1.go @@ -1,7 +1,4 @@ -// $G $D/embed0.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 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -9,40 +6,4 @@ // Test that embedded interface types can have local methods. -package main - -import "./embed0" - -type T int -func (t T) m() {} - -type I interface { m() } -type J interface { I } - -type PI interface { p.I } -type PJ interface { p.J } - -func main() { - var i I - var j J - var t T - i = t - j = t - _ = i - _ = j - i = j - _ = i - j = i - _ = j - var pi PI - var pj PJ - var pt p.T - pi = pt - pj = pt - _ = pi - _ = pj - pi = pj - _ = pi - pj = pi - _ = pj -} +package ignored diff --git a/test/interface/private.dir/private1.go b/test/interface/private.dir/private1.go new file mode 100644 index 0000000000..75eee51f5a --- /dev/null +++ b/test/interface/private.dir/private1.go @@ -0,0 +1,18 @@ +// 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. + +// Imported by private.go, which should not be able to see the private method. + +package p + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() {} + +var X = new(Implementation) + diff --git a/test/interface/private.dir/prog.go b/test/interface/private.dir/prog.go new file mode 100644 index 0000000000..abea7d625c --- /dev/null +++ b/test/interface/private.dir/prog.go @@ -0,0 +1,33 @@ +// 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. + +// Test that unexported methods are not visible outside the package. +// Does not compile. + +package main + +import "./private1" + +type Exported interface { + private() +} + +type Implementation struct{} + +func (p *Implementation) private() {} + +func main() { + var x Exported + x = new(Implementation) + x.private() + + var px p.Exported + px = p.X + + px.private() // ERROR "private" + + px = new(Implementation) // ERROR "private" + + x = px // ERROR "private" +} diff --git a/test/interface/private.go b/test/interface/private.go index 0a42385ea7..a0da249c92 100644 --- a/test/interface/private.go +++ b/test/interface/private.go @@ -1,7 +1,4 @@ -// $G $D/${F}1.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 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -10,29 +7,4 @@ // Test that unexported methods are not visible outside the package. // Does not compile. -package main - -import "./private1" - -type Exported interface { - private() -} - -type Implementation struct{} - -func (p *Implementation) private() {} - -func main() { - var x Exported - x = new(Implementation) - x.private() - - var px p.Exported - px = p.X - - px.private() // ERROR "private" - - px = new(Implementation) // ERROR "private" - - x = px // ERROR "private" -} +package ignored diff --git a/test/interface/private1.go b/test/interface/private1.go deleted file mode 100644 index 3281c38be6..0000000000 --- a/test/interface/private1.go +++ /dev/null @@ -1,20 +0,0 @@ -// skip # used by private.go - -// 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. - -// Imported by private.go, which should not be able to see the private method. - -package p - -type Exported interface { - private() -} - -type Implementation struct{} - -func (p *Implementation) private() {} - -var X = new(Implementation) - diff --git a/test/interface/recursive1.dir/recursive1.go b/test/interface/recursive1.dir/recursive1.go new file mode 100644 index 0000000000..441f0ecaa5 --- /dev/null +++ b/test/interface/recursive1.dir/recursive1.go @@ -0,0 +1,15 @@ +// 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. + +// Mutually recursive type definitions imported and used by recursive1.go. + +package p + +type I1 interface { + F() I2 +} + +type I2 interface { + I1 +} diff --git a/test/interface/recursive1.dir/recursive2.go b/test/interface/recursive1.dir/recursive2.go new file mode 100644 index 0000000000..e8048c672b --- /dev/null +++ b/test/interface/recursive1.dir/recursive2.go @@ -0,0 +1,20 @@ +// 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 that the mutually recursive types in recursive1.go made it +// intact and with the same meaning, by assigning to or using them. + +package main + +import "./recursive1" + +func main() { + var i1 p.I1 + var i2 p.I2 + i1 = i2 + i2 = i1 + i1 = i2.F() + i2 = i1.F() + _, _ = i1, i2 +} diff --git a/test/interface/recursive1.go b/test/interface/recursive1.go index cc3cdc37f1..62f6108844 100644 --- a/test/interface/recursive1.go +++ b/test/interface/recursive1.go @@ -1,4 +1,4 @@ -// skip # used by recursive2 +// compiledir // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -6,12 +6,4 @@ // Mutually recursive type definitions imported and used by recursive1.go. -package p - -type I1 interface { - F() I2 -} - -type I2 interface { - I1 -} +package ignored diff --git a/test/interface/recursive2.go b/test/interface/recursive2.go deleted file mode 100644 index 3a1059960c..0000000000 --- a/test/interface/recursive2.go +++ /dev/null @@ -1,25 +0,0 @@ -// $G $D/recursive1.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 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 that the mutually recursive types in recursive1.go made it -// intact and with the same meaning, by assigning to or using them. - -package main - -import "./recursive1" - -func main() { - var i1 p.I1 - var i2 p.I2 - i1 = i2 - i2 = i1 - i1 = i2.F() - i2 = i1.F() - _, _ = i1, i2 -} -- cgit v1.2.1