github.com/stingnevermore/go@v0.0.0-20180120041312-3810f5bfed72/test/ken/simpconv.go (about) 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 arithmetic conversion. 8 9 package main 10 11 type vlong int64 12 type short int16 13 14 func main() { 15 s1 := vlong(0) 16 for i := short(0); i < 10; i = i + 1 { 17 s1 = s1 + vlong(i) 18 } 19 if s1 != 45 { 20 panic(s1) 21 } 22 23 s2 := float64(0) 24 for i := 0; i < 10; i = i + 1 { 25 s2 = s2 + float64(i) 26 } 27 if s2 != 45 { 28 panic(s2) 29 } 30 }