Russ Cox | 82e41cc | 2008-10-14 17:10:39 -0700 | [diff] [blame] | 1 | // $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 | |
| 7 | package main |
| 8 | |
Russ Cox | be2edb5 | 2009-03-03 08:39:12 -0800 | [diff] [blame] | 9 | var a = []int { 1,2, } |
| 10 | var b = [5]int { 1,2,3 } |
| 11 | var c = []int { 1 } |
| 12 | var d = [...]int { 1,2,3 } |
Russ Cox | 82e41cc | 2008-10-14 17:10:39 -0700 | [diff] [blame] | 13 | |
| 14 | func main() { |
| 15 | if len(a) != 2 { panicln("len a", len(a)) } |
| 16 | if len(b) != 5 { panicln("len b", len(b)) } |
Ken Thompson | 476e3cd | 2009-01-06 17:44:59 -0800 | [diff] [blame] | 17 | 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 Cox | 82e41cc | 2008-10-14 17:10:39 -0700 | [diff] [blame] | 34 | } |