summaryrefslogtreecommitdiff
path: root/test/fixedbugs/bug243.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixedbugs/bug243.go')
-rw-r--r--test/fixedbugs/bug243.go37
1 files changed, 32 insertions, 5 deletions
diff --git a/test/fixedbugs/bug243.go b/test/fixedbugs/bug243.go
index 236c14402..0c531968e 100644
--- a/test/fixedbugs/bug243.go
+++ b/test/fixedbugs/bug243.go
@@ -6,12 +6,14 @@
package main
-import (
- "net"
-)
+import "os"
+
+// Issue 481: closures and var declarations
+// with multiple variables assigned from one
+// function call.
func main() {
- var listen, _ = net.Listen("tcp", "127.0.0.1:0")
+ var listen, _ = Listen("tcp", "127.0.0.1:0")
go func() {
for {
@@ -20,6 +22,31 @@ func main() {
}
}()
- var conn, _ = net.Dial("tcp", "", listen.Addr().String())
+ var conn, _ = Dial("tcp", "", listen.Addr().String())
_ = conn
}
+
+// Simulated net interface to exercise bug
+// without involving a real network.
+type T chan int
+
+var global T
+
+func Listen(x, y string) (T, string) {
+ global = make(chan int)
+ return global, y
+}
+
+func (t T) Addr() os.Error {
+ return os.ErrorString("stringer")
+}
+
+func (t T) Accept() (int, string) {
+ return <-t, ""
+}
+
+func Dial(x, y, z string) (int, string) {
+ global <- 1
+ return 0, ""
+}
+