summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-06-03 11:31:24 +0200
committerOndřej Surý <ondrej@sury.org>2011-06-03 11:31:24 +0200
commit56135c623a865c501ab31cc940c0e22ece2673f4 (patch)
treef69e04e82bbf75bdab0f624430ef265425e62b35 /test
parent63d29fefab5290dc96e0a03ff70603aefa995887 (diff)
downloadgolang-56135c623a865c501ab31cc940c0e22ece2673f4.tar.gz
Imported Upstream version 2011.06.02upstream-weekly/2011.06.02
Diffstat (limited to 'test')
-rw-r--r--test/ddd1.go1
-rw-r--r--test/fixedbugs/bug226.dir/y.go2
-rw-r--r--test/fixedbugs/bug322.dir/lib.go (renamed from test/bugs/bug322.dir/lib.go)0
-rw-r--r--test/fixedbugs/bug322.dir/main.go (renamed from test/bugs/bug322.dir/main.go)7
-rw-r--r--test/fixedbugs/bug322.go (renamed from test/bugs/bug322.go)0
-rw-r--r--test/fixedbugs/bug342.go24
-rw-r--r--test/fixedbugs/bug343.go33
-rw-r--r--test/golden.out5
-rw-r--r--test/shift1.go36
-rw-r--r--test/shift2.go42
10 files changed, 137 insertions, 13 deletions
diff --git a/test/ddd1.go b/test/ddd1.go
index a0bc73814..96a358e1c 100644
--- a/test/ddd1.go
+++ b/test/ddd1.go
@@ -43,4 +43,5 @@ func bad(args ...int) {
var x int
_ = unsafe.Pointer(&x...) // ERROR "[.][.][.]"
_ = unsafe.Sizeof(x...) // ERROR "[.][.][.]"
+ _ = [...]byte("foo") // ERROR "[.][.][.]"
}
diff --git a/test/fixedbugs/bug226.dir/y.go b/test/fixedbugs/bug226.dir/y.go
index 01e8b7b43..c66d592b7 100644
--- a/test/fixedbugs/bug226.dir/y.go
+++ b/test/fixedbugs/bug226.dir/y.go
@@ -15,7 +15,7 @@ func f() {
_ = x.T{};
_ = x.T{Y:2};
- ok1.M(); // ERROR "assignment.*T"
+ ok1.M();
bad1 := *ok; // ERROR "assignment.*T"
bad2 := ok1; // ERROR "assignment.*T"
*ok4 = ok1; // ERROR "assignment.*T"
diff --git a/test/bugs/bug322.dir/lib.go b/test/fixedbugs/bug322.dir/lib.go
index 0de56d3d6..0de56d3d6 100644
--- a/test/bugs/bug322.dir/lib.go
+++ b/test/fixedbugs/bug322.dir/lib.go
diff --git a/test/bugs/bug322.dir/main.go b/test/fixedbugs/bug322.dir/main.go
index 0ab5b32e4..f403c7d32 100644
--- a/test/bugs/bug322.dir/main.go
+++ b/test/fixedbugs/bug322.dir/main.go
@@ -38,10 +38,3 @@ func main() {
var pi2 PI = pt
pi2.PM()
}
-
-/*
-These should not be errors anymore:
-
-bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver
-bug322.dir/main.go:32: implicit assignment of unexported field 'x' of lib.T in method receiver
-*/
diff --git a/test/bugs/bug322.go b/test/fixedbugs/bug322.go
index ad0e62dc8..ad0e62dc8 100644
--- a/test/bugs/bug322.go
+++ b/test/fixedbugs/bug322.go
diff --git a/test/fixedbugs/bug342.go b/test/fixedbugs/bug342.go
new file mode 100644
index 000000000..0852cdd34
--- /dev/null
+++ b/test/fixedbugs/bug342.go
@@ -0,0 +1,24 @@
+// 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.
+
+// Issue 1871.
+
+package p
+
+type a interface {
+ foo(x int) (x int) // ERROR "redeclared|redefinition"
+}
+
+var b interface {
+ bar(y int) (y int) // ERROR "redeclared|redefinition"
+}
+
+/*
+Previously:
+
+bug.go:1 x redclared in this block
+ previous declaration at bug.go:1
+*/
diff --git a/test/fixedbugs/bug343.go b/test/fixedbugs/bug343.go
new file mode 100644
index 000000000..efc87e3d7
--- /dev/null
+++ b/test/fixedbugs/bug343.go
@@ -0,0 +1,33 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug343
+
+// 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.
+
+// issue 1900
+
+package main
+
+func getArgs(data map[string]interface{}, keys ...string) map[string]string {
+ ret := map[string]string{}
+ var ok bool
+ for _, k := range keys {
+ ret[k], ok = data[k].(string)
+ if !ok {}
+ }
+ return ret
+}
+
+func main() {
+ x := getArgs(map[string]interface{}{"x":"y"}, "x")
+ if x["x"] != "y" {
+ println("BUG bug343", x)
+ }
+}
+
+
+/*
+typecheck [1008592b0]
+. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string
+bug343.go:15: internal compiler error: typecheck INDREG
+*/
diff --git a/test/golden.out b/test/golden.out
index 725e8de44..4400e41dd 100644
--- a/test/golden.out
+++ b/test/golden.out
@@ -161,8 +161,3 @@ panic: interface conversion: interface is main.T, not main.T
0x0
== bugs/
-
-=========== bugs/bug322.go
-bugs/bug322.dir/main.go:19: implicit assignment of unexported field 'x' of lib.T in method receiver
-bugs/bug322.dir/main.go:32: implicit assignment of unexported field 'x' of lib.T in method receiver
-BUG: fails incorrectly
diff --git a/test/shift1.go b/test/shift1.go
new file mode 100644
index 000000000..8fa48a03c
--- /dev/null
+++ b/test/shift1.go
@@ -0,0 +1,36 @@
+// errchk $G -e $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.
+
+// Issue 1708, illegal cases.
+
+package p
+
+func f(x int) int { return 0 }
+func g(x interface{}) int { return 0 }
+func h(x float64) int { return 0 }
+
+// from the spec
+var (
+ s uint = 33
+ u = 1.0 << s // ERROR "invalid operation"
+ v float32 = 1 << s // ERROR "invalid operation"
+)
+
+// non-constant shift expressions
+var (
+ e1 = g(2.0 << s) // ERROR "invalid operation"
+ f1 = h(2 << s) // ERROR "invalid operation"
+ g1 int64 = 1.1 << s // ERROR "truncated"
+)
+
+// constant shift expressions
+const c uint = 65
+
+var (
+ a2 int = 1.0 << c // ERROR "overflow"
+ b2 = 1.0 << c // ERROR "overflow"
+ d2 = f(1.0 << c) // ERROR "overflow"
+)
diff --git a/test/shift2.go b/test/shift2.go
new file mode 100644
index 000000000..ec4c7addc
--- /dev/null
+++ b/test/shift2.go
@@ -0,0 +1,42 @@
+// $G $D/$F.go || echo BUG: shift2
+
+// 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.
+
+// Issue 1708, legal cases.
+
+package p
+
+func f(x int) int { return 0 }
+func g(x interface{}) int { return 0 }
+func h(x float64) int { return 0 }
+
+// from the spec
+var (
+ s uint = 33
+ i = 1 << s // 1 has type int
+ j int32 = 1 << s // 1 has type int32; j == 0
+ k = uint64(1 << s) // 1 has type uint64; k == 1<<33
+ m int = 1.0 << s // legal: 1.0 has type int
+ w int64 = 1.0 << 33 // legal: 1.0<<33 is a constant shift expression
+)
+
+// non-constant shift expressions
+var (
+ a1 int = 2.0 << s // typeof(2.0) is int in this context => legal shift
+ d1 = f(2.0 << s) // typeof(2.0) is int in this context => legal shift
+)
+
+// constant shift expressions
+const c uint = 5
+
+var (
+ a2 int = 2.0 << c // a2 == 64 (type int)
+ b2 = 2.0 << c // b2 == 64 (untyped integer)
+ _ = f(b2) // verify b2 has type int
+ c2 float64 = 2 << c // c2 == 64.0 (type float64)
+ d2 = f(2.0 << c) // == f(64)
+ e2 = g(2.0 << c) // == g(int(64))
+ f2 = h(2 << c) // == h(float64(64.0))
+)