diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /test/interface | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-04b08da9af0c450d645ab7389d1467308cfc2db8.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'test/interface')
-rw-r--r-- | test/interface/embed1.dir/embed0.go (renamed from test/interface/embed0.go) | 2 | ||||
-rw-r--r-- | test/interface/embed1.dir/embed1.go | 43 | ||||
-rw-r--r-- | test/interface/embed1.go | 40 | ||||
-rw-r--r-- | test/interface/explicit.go | 8 | ||||
-rw-r--r-- | test/interface/private.dir/private1.go (renamed from test/interface/private1.go) | 2 | ||||
-rw-r--r-- | test/interface/private.dir/prog.go | 33 | ||||
-rw-r--r-- | test/interface/private.go | 29 | ||||
-rw-r--r-- | test/interface/recursive1.dir/recursive1.go | 15 | ||||
-rw-r--r-- | test/interface/recursive1.dir/recursive2.go (renamed from test/interface/recursive2.go) | 2 | ||||
-rw-r--r-- | test/interface/recursive1.go | 12 |
10 files changed, 104 insertions, 82 deletions
diff --git a/test/interface/embed0.go b/test/interface/embed1.dir/embed0.go index e2ee20ade..728bec74e 100644 --- a/test/interface/embed0.go +++ b/test/interface/embed1.dir/embed0.go @@ -1,5 +1,3 @@ -// 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. diff --git a/test/interface/embed1.dir/embed1.go b/test/interface/embed1.dir/embed1.go new file mode 100644 index 000000000..7dfb1dbc0 --- /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 ee502a162..784b82bb0 100644 --- a/test/interface/embed1.go +++ b/test/interface/embed1.go @@ -1,4 +1,4 @@ -// $G $D/embed0.go && $G $D/$F.go && $L $F.$A && ./$A.out +// rundir // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -6,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/explicit.go b/test/interface/explicit.go index d19480a68..eb81156e0 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -15,6 +15,10 @@ type T struct { var t *T +type X int + +func (x *X) M() {} + type I interface { M() } @@ -40,7 +44,7 @@ func main() { // because i has an extra method // that t does not, so i cannot contain a t. i = t // ERROR "incompatible|missing M method" - t = i // ERROR "incompatible|need type assertion" + t = i // ERROR "incompatible|assignment$" i = i2 // ok i2 = i // ERROR "incompatible|missing N method" @@ -66,6 +70,8 @@ func (Int) M(float64) {} var _ = m.(Int) // ERROR "impossible type assertion" +var _ = m.(X) // ERROR "pointer receiver" + var ii int var jj Int diff --git a/test/interface/private1.go b/test/interface/private.dir/private1.go index 3281c38be..75eee51f5 100644 --- a/test/interface/private1.go +++ b/test/interface/private.dir/private1.go @@ -1,5 +1,3 @@ -// 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. diff --git a/test/interface/private.dir/prog.go b/test/interface/private.dir/prog.go new file mode 100644 index 000000000..abea7d625 --- /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 14dfc1ae5..a0da249c9 100644 --- a/test/interface/private.go +++ b/test/interface/private.go @@ -1,4 +1,4 @@ -// $G $D/${F}1.go && errchk $G $D/$F.go +// errorcheckdir // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -7,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/recursive1.dir/recursive1.go b/test/interface/recursive1.dir/recursive1.go new file mode 100644 index 000000000..441f0ecaa --- /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/recursive2.go b/test/interface/recursive1.dir/recursive2.go index 5129ceb02..e8048c672 100644 --- a/test/interface/recursive2.go +++ b/test/interface/recursive1.dir/recursive2.go @@ -1,5 +1,3 @@ -// $G $D/recursive1.go && $G $D/$F.go - // 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. diff --git a/test/interface/recursive1.go b/test/interface/recursive1.go index cc3cdc37f..62f610884 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 |