summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-06-25 14:44:09 -0700
committerRuss Cox <rsc@golang.org>2009-06-25 14:44:09 -0700
commitf682aa9bc49c7ea792addc0056955a22c8e42385 (patch)
tree5cc2ca003b31c3178e73e2401433c0e5d99d69e5 /test
parentca756e1b7cec38a1c835853050d5f660baf9a43a (diff)
downloadgo-f682aa9bc49c7ea792addc0056955a22c8e42385.tar.gz
update tests for CL 30586.
won't submit unless 30586 goes in. R=r DELTA=94 (65 added, 16 deleted, 13 changed) OCL=30592 CL=30755
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/bug022.go4
-rw-r--r--test/fixedbugs/bug119.go3
-rw-r--r--test/fixedbugs/bug143.go7
-rw-r--r--test/indirect.go30
-rw-r--r--test/indirect1.go69
5 files changed, 83 insertions, 30 deletions
diff --git a/test/fixedbugs/bug022.go b/test/fixedbugs/bug022.go
index 229f87921..6ea233d05 100644
--- a/test/fixedbugs/bug022.go
+++ b/test/fixedbugs/bug022.go
@@ -9,7 +9,7 @@ package main
func putint(digits *string) {
var i byte;
i = (*digits)[7]; // compiles
- i = digits[7]; // doesn't compile
+ i = digits[7]; // ERROR "illegal"
}
func main() {
@@ -21,5 +21,5 @@ func main() {
bug022.go:8: illegal types for operand
(*<string>*STRING) INDEXPTR (<int32>INT32)
bug022.go:8: illegal types for operand
- (<uint8>UINT8) AS
+ (<uint8>UINT8) AS
*/
diff --git a/test/fixedbugs/bug119.go b/test/fixedbugs/bug119.go
index 8e51ef2ce..c4ce80ce0 100644
--- a/test/fixedbugs/bug119.go
+++ b/test/fixedbugs/bug119.go
@@ -12,7 +12,6 @@ func foo(a []int) int {
func main() {
a := &[]int{12};
- if x := a[0] ; x != 12 { panicln(1) }
if x := (*a)[0]; x != 12 { panicln(2) }
if x := foo(*a) ; x != 12 { panicln(3) } // fails (x is incorrect)
}
@@ -28,5 +27,5 @@ panic on line 83 PC=0x14d6
0x52bb?zi
mainstart(1, 0, 1606416432, ...)
mainstart(0x1, 0x7fff5fbff830, 0x0, ...)
-uetli:~/Source/go1/test/bugs gri$
+uetli:~/Source/go1/test/bugs gri$
*/
diff --git a/test/fixedbugs/bug143.go b/test/fixedbugs/bug143.go
index f6001376a..cb8631051 100644
--- a/test/fixedbugs/bug143.go
+++ b/test/fixedbugs/bug143.go
@@ -8,9 +8,9 @@ package main
type myMap map[string] int;
-func f() *myMap {
+func f() myMap {
m := make(map[string] int);
- return &m
+ return m
}
func main() {
@@ -24,9 +24,6 @@ func main() {
x, ok := (*mp)["key"]
}
{
- x, ok := mp["key"]
- }
- {
x, ok := f()["key"]
}
{
diff --git a/test/indirect.go b/test/indirect.go
index 4200d382a..cbe3e0df2 100644
--- a/test/indirect.go
+++ b/test/indirect.go
@@ -33,11 +33,7 @@ func crash()
// these uses of nil pointers
// would crash but should type check
println("crash",
- len(m1)+
- len(s1)+
- len(a1)+
- len(b1)+
- cap(b1));
+ len(a1) + cap(a1));
}
func nocrash()
@@ -49,19 +45,15 @@ func nocrash()
// it might also help in the traceback.
x :=
len(m0)+
- len(m2)+
- len(m3)+
- len(m4);
- if x != 2 {
+ len(m3);
+ if x != 1 {
panicln("wrong maplen");
}
x =
len(s0)+
- len(s2)+
- len(s3)+
- len(s4);
- if x != 2 {
+ len(s3);
+ if x != 1 {
panicln("wrong stringlen");
}
@@ -74,19 +66,15 @@ func nocrash()
x =
len(b0)+
- len(b2)+
- len(b3)+
- len(b4);
- if x != 6 {
+ len(b3);
+ if x != 3 {
panicln("wrong slicelen");
}
x =
cap(b0)+
- cap(b2)+
- cap(b3)+
- cap(b4);
- if x != 6 {
+ cap(b3);
+ if x != 3 {
panicln("wrong slicecap");
}
}
diff --git a/test/indirect1.go b/test/indirect1.go
new file mode 100644
index 000000000..b5df15d06
--- /dev/null
+++ b/test/indirect1.go
@@ -0,0 +1,69 @@
+// errchk $G -e $D/$F.go
+
+// 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
+
+var m0 map[string]int
+var m1 *map[string]int
+var m2 *map[string]int = &m0
+var m3 map[string]int = map[string]int{"a": 1}
+var m4 *map[string]int = &m3
+
+var s0 string
+var s1 *string
+var s2 *string = &s0
+var s3 string = "a"
+var s4 *string = &s3
+
+var a0 [10]int
+var a1 *[10]int
+var a2 *[10]int = &a0
+
+var b0 []int
+var b1 *[]int
+var b2 *[]int = &b0
+var b3 []int = []int{1, 2, 3}
+var b4 *[]int = &b3
+
+func f()
+{
+ // this is spaced funny so that
+ // the compiler will print a different
+ // line number for each len call when
+ // it decides there are type errors.
+ x :=
+ len(m0)+
+ len(m1)+ // ERROR "illegal"
+ len(m2)+ // ERROR "illegal"
+ len(m3)+
+ len(m4)+ // ERROR "illegal"
+
+ len(s0)+
+ len(s1)+ // ERROR "illegal"
+ len(s2)+ // ERROR "illegal"
+ len(s3)+
+ len(s4)+ // ERROR "illegal"
+
+ len(a0)+
+ len(a1)+
+ len(a2)+
+
+ cap(a0)+
+ cap(a1)+
+ cap(a2)+
+
+ len(b0)+
+ len(b1)+ // ERROR "illegal"
+ len(b2)+ // ERROR "illegal"
+ len(b3)+
+ len(b4)+ // ERROR "illegal"
+
+ cap(b0)+
+ cap(b1)+ // ERROR "illegal"
+ cap(b2)+ // ERROR "illegal"
+ cap(b3)+
+ cap(b4); // ERROR "illegal"
+}