summaryrefslogtreecommitdiff
path: root/test/complit.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-09-04 13:35:19 -0700
committerRob Pike <r@golang.org>2008-09-04 13:35:19 -0700
commit6bf63ee02b7f98f4e5b09d90989ee91d8725b9a5 (patch)
treeafaed709ef7034c832ab1bbbaeccb313f8a08c6f /test/complit.go
parent7653603e0468b03f01259f961e145fb46fa14b59 (diff)
downloadgo-6bf63ee02b7f98f4e5b09d90989ee91d8725b9a5.tar.gz
extend composite literal test.
update tests. update golden.out R=gri OCL=14816 CL=14816
Diffstat (limited to 'test/complit.go')
-rw-r--r--test/complit.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/complit.go b/test/complit.go
index bba690cfe..21bf8e4a7 100644
--- a/test/complit.go
+++ b/test/complit.go
@@ -8,6 +8,20 @@ package main
type T struct { i int; f float; s string; next *T }
+type R struct { num int }
+
+func itor(a int) *R {
+ r := new(R);
+ r.num = a;
+ return r;
+}
+
+func eq(a *[]*R) {
+ for i := 0; i < len(a); i++ {
+ if a[i].num != i { panic("bad") }
+ }
+}
+
func main() {
var t T;
t = T(0, 7.2, "hi", &t);
@@ -18,7 +32,7 @@ func main() {
a1 := []int(1,2,3);
if len(a1) != 3 { panic("a1") }
a2 := [10]int(1,2,3);
- if len(a2) != 10 || a2[3] != 0 { panic("a2") }
+ if len(a2) != 10 || cap(a2) != 10 { panic("a2") }
//a3 := [10]int(1,2,3,); // BUG: trailing commas not allowed
//if len(a3) != 10 || a2[3] != 0 { panic("a3") }
@@ -41,4 +55,6 @@ func main() {
m := map[string]float("one":1.0, "two":2.0, "pi":22./7.);
if len(m) != 3 { panic("m") }
+
+ eq(&[]*R(itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)));
}