OSDN Git Service

Remove the types float and complex.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / ken / cplx1.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2010 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 package main
8
9 const (
10         R = 5
11         I = 6i
12
13         C1 = R + I // ADD(5,6)
14 )
15
16 func main() {
17         var b bool
18
19         // constants
20         b = (5 + 6i) == C1
21         if !b {
22                 println("const bool 1", b)
23                 panic("fail")
24         }
25
26         b = (5 + 6i) != C1
27         if b {
28                 println("const bool 2", b)
29                 panic("fail")
30         }
31
32         b = C1 == (5 + 6i)
33         if !b {
34                 println("const bool 3", b)
35                 panic("fail")
36         }
37
38         b = C1 != (5 + 6i)
39         if b {
40                 println("const bool 4", b)
41                 panic("fail")
42         }
43
44         // vars passed through parameters
45         booltest(5+6i, true)
46         booltest(5+7i, false)
47         booltest(6+6i, false)
48         booltest(6+9i, false)
49 }
50
51 func booltest(a complex64, r bool) {
52         var b bool
53
54         b = a == C1
55         if b != r {
56                 println("param bool 1", a, b, r)
57                 panic("fail")
58         }
59
60         b = a != C1
61         if b == r {
62                 println("param bool 2", a, b, r)
63                 panic("fail")
64         }
65
66         b = C1 == a
67         if b != r {
68                 println("param bool 3", a, b, r)
69                 panic("fail")
70         }
71
72         b = C1 != a
73         if b == r {
74                 println("param bool 4", a, b, r)
75                 panic("fail")
76         }
77
78         if r {
79                 if a != C1 {
80                         println("param bool 5", a, b, r)
81                         panic("fail")
82                 }
83                 if C1 != a {
84                         println("param bool 6", a, b, r)
85                         panic("fail")
86                 }
87         } else {
88                 if a == C1 {
89                         println("param bool 6", a, b, r)
90                         panic("fail")
91                 }
92                 if C1 == a {
93                         println("param bool 7", a, b, r)
94                         panic("fail")
95                 }
96         }
97 }