aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue23719.go42
-rw-r--r--test/fixedbugs/issue23812.go34
-rw-r--r--test/fixedbugs/issue24817.go64
3 files changed, 140 insertions, 0 deletions
diff --git a/test/fixedbugs/issue23719.go b/test/fixedbugs/issue23719.go
new file mode 100644
index 0000000000..c97e63636c
--- /dev/null
+++ b/test/fixedbugs/issue23719.go
@@ -0,0 +1,42 @@
+// run
+
+// Copyright 2018 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() {
+ v1 := [2]int32{-1, 88}
+ v2 := [2]int32{-1, 99}
+ if v1 == v2 {
+ panic("bad comparison")
+ }
+
+ w1 := [2]int16{-1, 88}
+ w2 := [2]int16{-1, 99}
+ if w1 == w2 {
+ panic("bad comparison")
+ }
+ x1 := [4]int16{-1, 88, 88, 88}
+ x2 := [4]int16{-1, 99, 99, 99}
+ if x1 == x2 {
+ panic("bad comparison")
+ }
+
+ a1 := [2]int8{-1, 88}
+ a2 := [2]int8{-1, 99}
+ if a1 == a2 {
+ panic("bad comparison")
+ }
+ b1 := [4]int8{-1, 88, 88, 88}
+ b2 := [4]int8{-1, 99, 99, 99}
+ if b1 == b2 {
+ panic("bad comparison")
+ }
+ c1 := [8]int8{-1, 88, 88, 88, 88, 88, 88, 88}
+ c2 := [8]int8{-1, 99, 99, 99, 99, 99, 99, 99}
+ if c1 == c2 {
+ panic("bad comparison")
+ }
+}
diff --git a/test/fixedbugs/issue23812.go b/test/fixedbugs/issue23812.go
new file mode 100644
index 0000000000..0a40deb212
--- /dev/null
+++ b/test/fixedbugs/issue23812.go
@@ -0,0 +1,34 @@
+// run
+
+// Copyright 2018 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
+
+import "fmt"
+
+func main() {
+ want := int32(0x3edae8)
+ got := foo(1)
+ if want != got {
+ panic(fmt.Sprintf("want %x, got %x", want, got))
+ }
+}
+
+func foo(a int32) int32 {
+ return shr1(int32(shr2(int64(0x14ff6e2207db5d1f), int(a))), 4)
+}
+
+func shr1(n int32, m int) int32 { return n >> uint(m) }
+
+func shr2(n int64, m int) int64 {
+ if m < 0 {
+ m = -m
+ }
+ if m >= 64 {
+ return n
+ }
+
+ return n >> uint(m)
+}
diff --git a/test/fixedbugs/issue24817.go b/test/fixedbugs/issue24817.go
new file mode 100644
index 0000000000..ba2a138ed3
--- /dev/null
+++ b/test/fixedbugs/issue24817.go
@@ -0,0 +1,64 @@
+// run
+
+// Copyright 2018 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.
+
+// Check all ways to compare a non-constant string to the empty string.
+
+package main
+
+import (
+ "fmt"
+ "os"
+)
+
+var (
+ s = "abc"
+ e = ""
+ failed bool
+)
+
+func main() {
+ want(true, "" < s, `"" < s`)
+ want(false, s < "", `s < ""`)
+ want(false, "" < e, `"" < e`)
+ want(false, e < "", `e < ""`)
+
+ want(true, "" <= s, `"" <= s`)
+ want(false, s <= "", `s <= ""`)
+ want(true, "" <= e, `"" <= e`)
+ want(true, e <= "", `e <= ""`)
+
+ want(false, "" > s, `"" > s`)
+ want(true, s > "", `s > ""`)
+ want(false, "" > e, `"" > e`)
+ want(false, e > "", `e > ""`)
+
+ want(false, "" >= s, `"" >= s`)
+ want(true, s >= "", `s >= ""`)
+ want(true, "" >= e, `"" >= e`)
+ want(true, e >= "", `e >= ""`)
+
+ want(false, "" == s, `"" == s`)
+ want(false, s == "", `s == ""`)
+ want(true, "" == e, `"" == e`)
+ want(true, e == "", `e == ""`)
+
+ want(true, "" != s, `"" != s`)
+ want(true, s != "", `s != ""`)
+ want(false, "" != e, `"" != e`)
+ want(false, e != "", `e != ""`)
+
+ if failed {
+ os.Exit(1)
+ }
+}
+
+//go:noinline
+func want(b bool, have bool, msg string) {
+ if b != have {
+ fmt.Println(msg)
+ failed = true
+ }
+}