summaryrefslogtreecommitdiff
path: root/test/complit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-12-02 14:13:12 -0500
committerRuss Cox <rsc@golang.org>2011-12-02 14:13:12 -0500
commit5940e43ea9f3da262a4d2740986c5d132fde21de (patch)
treec4bc220d6b2d504a65b26e3663006ef149e1033c /test/complit.go
parent64e6f7ac547df3d1dc0dfbc6056d34e45f56cc16 (diff)
downloadgo-5940e43ea9f3da262a4d2740986c5d132fde21de.tar.gz
gc: composite literals as per Go 1
R=ken2 CC=golang-dev http://codereview.appspot.com/5450067
Diffstat (limited to 'test/complit.go')
-rw-r--r--test/complit.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/complit.go b/test/complit.go
index f5f7aca9d..c9de616f5 100644
--- a/test/complit.go
+++ b/test/complit.go
@@ -31,6 +31,18 @@ func eq(a []*R) {
}
}
+func teq(t *T, n int) {
+ for i := 0; i < n; i++ {
+ if t == nil || t.i != i {
+ panic("bad")
+ }
+ t = t.next
+ }
+ if t != nil {
+ panic("bad")
+ }
+}
+
type P struct {
a, b int
}
@@ -46,6 +58,9 @@ func main() {
var tp *T
tp = &T{0, 7.2, "hi", &t}
+ tl := &T{i: 0, next: {i: 1, next: {i: 2, next: {i: 3, next: {i: 4}}}}}
+ teq(tl, 5)
+
a1 := []int{1, 2, 3}
if len(a1) != 3 {
panic("a1")
@@ -93,6 +108,7 @@ func main() {
}
eq([]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)})
+ eq([]*R{{0}, {1}, {2}, {3}, {4}, {5}})
p1 := NewP(1, 2)
p2 := NewP(1, 2)