~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to test/const.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
package main
10
10
 
 
11
import "os"
 
12
 
11
13
const (
12
 
        c0 = 0
13
 
        cm1 = -1
14
 
        chuge = 1 << 100
 
14
        c0      = 0
 
15
        cm1     = -1
 
16
        chuge   = 1 << 100
15
17
        chuge_1 = chuge - 1
16
 
        c1 = chuge >> 100
17
 
        c3div2 = 3/2
18
 
        c1e3 = 1e3
 
18
        c1      = chuge >> 100
 
19
        c3div2  = 3 / 2
 
20
        c1e3    = 1e3
19
21
 
20
 
        ctrue = true
 
22
        ctrue  = true
21
23
        cfalse = !ctrue
22
24
)
23
25
 
24
26
const (
25
 
        f0 = 0.0
26
 
        fm1 = -1.
27
 
        fhuge float64 = 1 << 100
 
27
        f0              = 0.0
 
28
        fm1             = -1.
 
29
        fhuge   float64 = 1 << 100
28
30
        fhuge_1 float64 = chuge - 1
29
 
        f1 float64 = chuge >> 100
30
 
        f3div2 = 3./2.
31
 
        f1e3 float64 = 1e3
 
31
        f1      float64 = chuge >> 100
 
32
        f3div2          = 3. / 2.
 
33
        f1e3    float64 = 1e3
32
34
)
33
35
 
34
36
func assert(t bool, s string) {
41
43
        assert(c0 == 0, "c0")
42
44
        assert(c1 == 1, "c1")
43
45
        assert(chuge > chuge_1, "chuge")
44
 
        assert(chuge_1 + 1 == chuge, "chuge 1")
45
 
        assert(chuge + cm1 +1  == chuge, "cm1")
 
46
        assert(chuge_1+1 == chuge, "chuge 1")
 
47
        assert(chuge+cm1+1 == chuge, "cm1")
46
48
        assert(c3div2 == 1, "3/2")
47
49
        assert(c1e3 == 1000, "c1e3 int")
48
50
        assert(c1e3 == 1e3, "c1e3 float")
81
83
func floats() {
82
84
        assert(f0 == c0, "f0")
83
85
        assert(f1 == c1, "f1")
84
 
        assert(fhuge == fhuge_1, "fhuge")       // float64 can't distinguish fhuge, fhuge_1.
85
 
        assert(fhuge_1 + 1 == fhuge, "fhuge 1")
86
 
        assert(fhuge + fm1 +1  == fhuge, "fm1")
 
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.
 
89
        }
 
90
        assert(fhuge_1+1 == fhuge, "fhuge 1")
 
91
        assert(fhuge+fm1+1 == fhuge, "fm1")
87
92
        assert(f3div2 == 1.5, "3./2.")
88
93
        assert(f1e3 == 1000, "f1e3 int")
89
94
        assert(f1e3 == 1.e3, "f1e3 float")