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.
7 // Test simple boolean and numeric constants.
29 fhuge
float64 = 1 << 100
30 fhuge_1
float64 = chuge
- 1
31 f1
float64 = chuge
>> 100
36 func assert(t
bool, s
string) {
45 assert(chuge
> chuge_1
, "chuge")
46 assert(chuge_1
+1 == chuge
, "chuge 1")
47 assert(chuge
+cm1
+1 == chuge
, "cm1")
48 assert(c3div2
== 1, "3/2")
49 assert(c1e3
== 1000, "c1e3 int")
50 assert(c1e3
== 1e3
, "c1e3 float")
52 // verify that all (in range) are assignable as ints
55 assert(i
== c0
, "i == c0")
57 assert(i
== cm1
, "i == cm1")
59 assert(i
== c1
, "i == c1")
61 assert(i
== c3div2
, "i == c3div2")
63 assert(i
== c1e3
, "i == c1e3")
65 // verify that all are assignable as floats
68 assert(f
== c0
, "f == c0")
70 assert(f
== cm1
, "f == cm1")
72 assert(f
== chuge
, "f == chuge")
74 assert(f
== chuge_1
, "f == chuge_1")
76 assert(f
== c1
, "f == c1")
78 assert(f
== c3div2
, "f == c3div2")
80 assert(f
== c1e3
, "f == c1e3")
84 assert(f0
== c0
, "f0")
85 assert(f1
== c1
, "f1")
86 // TODO(gri): exp/ssa/interp constant folding is incorrect.
87 if os
.Getenv("GOSSAINTERP") == "" {
88 assert(fhuge
== fhuge_1
, "fhuge") // float64 can't distinguish fhuge, fhuge_1.
90 assert(fhuge_1
+1 == fhuge
, "fhuge 1")
91 assert(fhuge
+fm1
+1 == fhuge
, "fm1")
92 assert(f3div2
== 1.5, "3./2.")
93 assert(f1e3
== 1000, "f1e3 int")
94 assert(f1e3
== 1.e3
, "f1e3 float")
96 // verify that all (in range) are assignable as ints
99 assert(i
== f0
, "i == f0")
101 assert(i
== fm1
, "i == fm1")
103 // verify that all are assignable as floats
106 assert(f
== f0
, "f == f0")
108 assert(f
== fm1
, "f == fm1")
110 assert(f
== fhuge
, "f == fhuge")
112 assert(f
== fhuge_1
, "f == fhuge_1")
114 assert(f
== f1
, "f == f1")
116 assert(f
== f3div2
, "f == f3div2")
118 assert(f
== f1e3
, "f == f1e3")
125 assert(ctrue
== true, "ctrue == true")
126 assert(cfalse
== false, "cfalse == false")