Source file
test/ken/cplx5.go
1
2
3
4
5
6
7
8
9 package main
10
11 var a [12]complex128
12 var s []complex128
13 var c chan complex128
14 var f struct {
15 c complex128
16 }
17 var m map[complex128]complex128
18
19 func main() {
20
21 for i := 0; i < len(a); i++ {
22 a[i] = complex(float64(i), float64(-i))
23 }
24 if a[5] != 5-5i {
25 panic(a[5])
26 }
27
28
29 s = make([]complex128, len(a))
30 for i := 0; i < len(s); i++ {
31 s[i] = a[i]
32 }
33 if s[5] != 5-5i {
34 panic(s[5])
35 }
36
37
38 c = make(chan complex128)
39 go chantest(c)
40 vc := <-c
41 if vc != 5-5i {
42 panic(vc)
43 }
44
45
46 v := a[5]
47 pv := &v
48 if *pv != 5-5i {
49 panic(*pv)
50 }
51
52
53 f.c = a[5]
54 if f.c != 5-5i {
55 panic(f.c)
56 }
57
58
59 m = make(map[complex128]complex128)
60 for i := 0; i < len(s); i++ {
61 m[-a[i]] = a[i]
62 }
63 if m[5i-5] != 5-5i {
64 panic(m[5i-5])
65 }
66 vm := m[complex(-5, 5)]
67 if vm != 5-5i {
68 panic(vm)
69 }
70 }
71
72 func chantest(c chan complex128) { c <- a[5] }
73
View as plain text