summaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/bug320.go45
-rw-r--r--test/fixedbugs/bug321.go30
-rw-r--r--test/fixedbugs/bug322.go20
3 files changed, 95 insertions, 0 deletions
diff --git a/test/fixedbugs/bug320.go b/test/fixedbugs/bug320.go
new file mode 100644
index 000000000..06d41f2ed
--- /dev/null
+++ b/test/fixedbugs/bug320.go
@@ -0,0 +1,45 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// 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.
+
+package main
+
+func main() {
+ c := make(chan int, 1)
+ dummy := make(chan int)
+ v := 0x12345678
+ for i := 0; i < 10; i++ {
+ // 6g had a bug that caused select to pass &t to
+ // selectrecv before allocating the memory for t,
+ // which caused non-deterministic crashes.
+ // This test looks for the bug by checking that the
+ // value received actually ends up in t.
+ // If the allocation happens after storing through
+ // whatever garbage &t holds, the later reference
+ // to t in the case body will use the new pointer and
+ // not see the received value.
+ v += 0x1020304
+ c <- v
+ select {
+ case t := <-c:
+ go func() {
+ f(t)
+ }()
+ escape(&t)
+ if t != v {
+ println(i, v, t)
+ panic("wrong values")
+ }
+ case dummy <- 1:
+ }
+ }
+}
+
+func escape(*int) {
+}
+
+func f(int) {
+}
+
diff --git a/test/fixedbugs/bug321.go b/test/fixedbugs/bug321.go
new file mode 100644
index 000000000..d0595ff59
--- /dev/null
+++ b/test/fixedbugs/bug321.go
@@ -0,0 +1,30 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug321
+
+// 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.
+
+// Troublesome floating point constants. Issue 1463.
+
+package main
+
+import "fmt"
+
+func check(test string, got, want float64) bool {
+ if got != want {
+ fmt.Println(test, "got", got, "want", want)
+ return false
+ }
+ return true
+}
+
+func main() {
+ good := true
+ // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
+ good = good && check("2.2250738585072012e-308", 2.2250738585072012e-308, 2.2250738585072014e-308)
+ // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/
+ good = good && check("2.2250738585072011e-308", 2.2250738585072011e-308, 2.225073858507201e-308)
+ if !good {
+ panic("fail")
+ }
+}
diff --git a/test/fixedbugs/bug322.go b/test/fixedbugs/bug322.go
new file mode 100644
index 000000000..bfb528318
--- /dev/null
+++ b/test/fixedbugs/bug322.go
@@ -0,0 +1,20 @@
+// errchk $G $D/$F.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.
+
+package main
+
+type T struct{}
+type P *T
+
+func (t *T) Meth() {}
+func (t T) Meth2() {}
+
+func main() {
+ t := &T{}
+ p := P(t)
+ p.Meth() // ERROR "undefined \(type P"
+ p.Meth2() // ERROR "undefined \(type P"
+} \ No newline at end of file