Source file test/ken/simparray.go

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

View as plain text