~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to test/ken/simparray.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-04-20 17:36:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110420173648-ifergoxyrm832trd
Tags: upstream-2011.03.07.1
Import upstream version 2011.03.07.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// $G $D/$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
 
 
9
var b[10] float32;
 
10
 
 
11
func
 
12
main() {
 
13
        var a[10] float32;
 
14
 
 
15
        for i:=int16(5); i<10; i=i+1 {
 
16
                a[i] = float32(i);
 
17
        }
 
18
 
 
19
        s1 := float32(0);
 
20
        for i:=5; i<10; i=i+1 {
 
21
                s1 = s1 + a[i];
 
22
        }
 
23
 
 
24
        if s1 != 35 { panic(s1); }
 
25
 
 
26
        for i:=int16(5); i<10; i=i+1 {
 
27
                b[i] = float32(i);
 
28
        }
 
29
 
 
30
        s2 := float32(0);
 
31
        for i:=5; i<10; i=i+1 {
 
32
                s2 = s2 + b[i];
 
33
        }
 
34
 
 
35
        if s2 != 35 { panic(s2); }
 
36
 
 
37
        b := new([100]int);
 
38
        for i:=0; i<100; i=i+1 {
 
39
                b[i] = i;
 
40
        }
 
41
 
 
42
        s3 := 0;
 
43
        for i:=0; i<100; i=i+1 {
 
44
                s3 = s3+b[i];
 
45
        }
 
46
 
 
47
        if s3 != 4950 { panic(s3); }
 
48
}