1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 func TestArrayLength(t *testing.T) {
18 {`[...]int{0,1,2,3,4,5,6,7,8,9}`, 10},
19 {`[...]int{9:0}`, 10},
20 {`[...]int{19-10:0}`, 10},
21 {`[...]int{19-10:0, 17-10:0, 18-10:0}`, 10},
24 for _, tt := range tests {
25 expr, err := parser.ParseExpr(tt.expr)
29 l, ok := arrayLength(expr.(*ast.CompositeLit))
31 t.Errorf("arrayLength did not recognize expression %#v", expr)
34 t.Errorf("arrayLength(%#v) = %v, want %v", expr, l, tt.length)