diff options
| author | Ian Lance Taylor <iant@golang.org> | 2009-03-20 16:30:54 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2009-03-20 16:30:54 -0700 |
| commit | 90943c8ee4cf2ccef11b72ba01ea729edd8b3c66 (patch) | |
| tree | f478651f2e5709a4be9e117e62731057951a6f5b | |
| parent | 7d443bb67acad4313ad38f297890620ce8cf7d1d (diff) | |
| download | go-90943c8ee4cf2ccef11b72ba01ea729edd8b3c66.tar.xz | |
Test that interfaces work in type switches.
R=ken,rsc
DELTA=30 (30 added, 0 deleted, 0 changed)
OCL=26599
CL=26604
| -rw-r--r-- | test/bugs/bug141.go | 30 | ||||
| -rw-r--r-- | test/golden.out | 4 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/bugs/bug141.go b/test/bugs/bug141.go new file mode 100644 index 0000000000..a2fd992c03 --- /dev/null +++ b/test/bugs/bug141.go @@ -0,0 +1,30 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should run + +// 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 + +type S struct { i int } +func (p *S) Get() int { return p.i } + +type Empty interface { +} + +type Getter interface { + Get() int; +} + +func f1(p Empty) { + switch x := p.(type) { + default: println("failed to match interface"); sys.Exit(1); + case Getter: break; + } + +} + +func main() { + var s S; + f1(&s); +} diff --git a/test/golden.out b/test/golden.out index c41d2d9e17..35a6aec8c6 100644 --- a/test/golden.out +++ b/test/golden.out @@ -141,6 +141,10 @@ bugs/bug140.go:6: syntax error near L1 bugs/bug140.go:7: syntax error near L2 BUG should compile +=========== bugs/bug141.go +failed to match interface +BUG: should run + =========== fixedbugs/bug016.go fixedbugs/bug016.go:7: constant -3 overflows uint |
