Source file
test/fixedbugs/issue11945.go
1
2
3
4
5
6
7 package main
8
9 import "fmt"
10
11
12 const (
13 _ = real(0)
14 _ = imag(0)
15
16
17 Real0 = real(0)
18 Imag0 = imag(0)
19
20
21
22 _ int = real(1)
23 _ int = real('a')
24 _ int = real(2.0)
25 _ int = real(3i)
26
27 _ float32 = real(1)
28 _ float32 = real('a')
29 _ float32 = real(2.1)
30 _ float32 = real(3.2i)
31
32 _ float64 = real(1)
33 _ float64 = real('a')
34 _ float64 = real(2.1)
35 _ float64 = real(3.2i)
36
37 _ int = imag(1)
38 _ int = imag('a')
39 _ int = imag(2.1 + 3i)
40 _ int = imag(3i)
41
42 _ float32 = imag(1)
43 _ float32 = imag('a')
44 _ float32 = imag(2.1 + 3.1i)
45 _ float32 = imag(3i)
46
47 _ float64 = imag(1)
48 _ float64 = imag('a')
49 _ float64 = imag(2.1 + 3.1i)
50 _ float64 = imag(3i)
51 )
52
53 var tests = []struct {
54 code string
55 got, want interface{}
56 }{
57 {"real(1)", real(1), 1.0},
58 {"real('a')", real('a'), float64('a')},
59 {"real(2.0)", real(2.0), 2.0},
60 {"real(3.2i)", real(3.2i), 0.0},
61
62 {"imag(1)", imag(1), 0.0},
63 {"imag('a')", imag('a'), 0.0},
64 {"imag(2.1 + 3.1i)", imag(2.1 + 3.1i), 3.1},
65 {"imag(3i)", imag(3i), 3.0},
66 }
67
68 func main() {
69
70 for _, test := range tests {
71 if test.got != test.want {
72 panic(fmt.Sprintf("%s: %v (%T) != %v (%T)", test.code, test.got, test.got, test.want, test.want))
73 }
74 }
75 }
76
View as plain text