1
2
3
4
5
6
7 package main
8
9 const (
10 c3div2 = 3/2;
11 f3div2 = 3./2.;
12 )
13
14 func assert(t bool, s string) {
15 if !t {
16 panic(s)
17 }
18 }
19
20 func main() {
21 var i int;
22 var f float64;
23
24 assert(c3div2 == 1, "3/2");
25 assert(f3div2 == 1.5, "3/2");
26
27 i = c3div2;
28 assert(i == c3div2, "i == c3div2");
29
30 f = c3div2;
31 assert(f == c3div2, "f == c3div2");
32
33 f = f3div2;
34 assert(f == f3div2, "f == f3div2");
35
36 i = f3div2;
37 assert(i == c3div2, "i == c3div2 from f3div2");
38 assert(i != f3div2, "i != f3div2");
39
40 const g float64 = 1.0;
41 i = g;
42
43 const h float64 = 3.14;
44 i = h;
45 i = int(h);
46 }
47
View as plain text