2012-02-17 04:50:37 +00:00
|
|
|
// run
|
2008-06-06 21:27:34 +00:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-24 05:24:24 +00:00
|
|
|
// Test simple arithmetic conversion.
|
|
|
|
|
2008-06-06 21:27:34 +00:00
|
|
|
package main
|
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
type vlong int64
|
|
|
|
type short int16
|
2008-07-07 17:03:10 +00:00
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
func main() {
|
|
|
|
s1 := vlong(0)
|
|
|
|
for i := short(0); i < 10; i = i + 1 {
|
|
|
|
s1 = s1 + vlong(i)
|
|
|
|
}
|
|
|
|
if s1 != 45 {
|
|
|
|
panic(s1)
|
2008-06-06 21:27:34 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:09:00 +00:00
|
|
|
s2 := float64(0)
|
|
|
|
for i := 0; i < 10; i = i + 1 {
|
|
|
|
s2 = s2 + float64(i)
|
|
|
|
}
|
|
|
|
if s2 != 45 {
|
|
|
|
panic(s2)
|
2008-06-06 21:27:34 +00:00
|
|
|
}
|
|
|
|
}
|