1 // $G $D/$F.go && $L $F.$A && ./$A.out
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.
9 // test range over channels
11 func gen(c chan int, lo, hi int) {
12 for i := lo; i <= hi; i++ {
18 func seq(lo, hi int) chan int {
26 for i := range seq('a', 'z') {
29 if s != "abcdefghijklmnopqrstuvwxyz" {
30 panicln("Wanted lowercase alphabet; got", s);
34 // test that range over array only evaluates
35 // the expression after "range" once.
38 func makearray() []int {
40 return []int{1,2,3,4,5};
45 for k, v := range makearray() {
49 panicln("range called makearray", nmake, "times");
52 panicln("wrong sum ranging over makearray");