blob: 44053f1459171f79afa1e5efec802234fd5c7886 [file] [log] [blame]
Russ Cox82e41cc2008-10-14 17:10:39 -07001// $G $F.go && $L $F.$A && ./$A.out
2
3// Copyright 2009 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
8
Russ Coxbe2edb52009-03-03 08:39:12 -08009var a = []int { 1,2, }
10var b = [5]int { 1,2,3 }
11var c = []int { 1 }
12var d = [...]int { 1,2,3 }
Russ Cox82e41cc2008-10-14 17:10:39 -070013
14func main() {
15 if len(a) != 2 { panicln("len a", len(a)) }
16 if len(b) != 5 { panicln("len b", len(b)) }
Ken Thompson476e3cd2009-01-06 17:44:59 -080017 if len(c) != 1 { panicln("len d", len(c)) }
18 if len(d) != 3 { panicln("len c", len(d)) }
19
20 if a[0] != 1 { panicln("a[0]", a[0]) }
21 if a[1] != 2 { panicln("a[1]", a[1]) }
22
23 if b[0] != 1 { panicln("b[0]", b[0]) }
24 if b[1] != 2 { panicln("b[1]", b[1]) }
25 if b[2] != 3 { panicln("b[2]", b[2]) }
26 if b[3] != 0 { panicln("b[3]", b[3]) }
27 if b[4] != 0 { panicln("b[4]", b[4]) }
28
29 if c[0] != 1 { panicln("c[0]", c[0]) }
30
31 if d[0] != 1 { panicln("d[0]", d[0]) }
32 if d[1] != 2 { panicln("d[1]", d[1]) }
33 if d[2] != 3 { panicln("d[2]", d[2]) }
Russ Cox82e41cc2008-10-14 17:10:39 -070034}