aboutsummaryrefslogtreecommitdiff
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
commit7dc9d8c72b5deb927028e9edfbc6015c5d0296be (patch)
tree3fdff8e3142745f7e26f98395cdb87c8ac62974f /test/complit.go
parent5f49456465f53f96bee03ac8cbe0d564e31576c2 (diff)
downloadgo-7dc9d8c72b5deb927028e9edfbc6015c5d0296be.tar.gz
go-7dc9d8c72b5deb927028e9edfbc6015c5d0296be.zip
gc: composite literals as per Go 1
R=ken2 CC=golang-dev https://golang.org/cl/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 f5f7aca9d9..c9de616f55 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)