Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / go.test / test / ken / cplx5.go
blobaf2a1c57d1243e0fc1efb935795f6dd9b8593977
1 // $G $D/$F.go && $L $F.$A && ./$A.out
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.
7 package main
9 var a [12]complex
10 var s []complex
11 var c chan complex
12 var f struct {
13 c complex
15 var m map[complex]complex
17 func main() {
18 // array of complex
19 for i := 0; i < len(a); i++ {
20 a[i] = cmplx(float(i), float(-i))
22 println(a[5])
24 // slice of complex
25 s = make([]complex, len(a))
26 for i := 0; i < len(s); i++ {
27 s[i] = a[i]
29 println(s[5])
31 // chan
32 c = make(chan complex)
33 go chantest(c)
34 println(<-c)
36 // pointer of complex
37 v := a[5]
38 pv := &v
39 println(*pv)
41 // field of complex
42 f.c = a[5]
43 println(f.c)
45 // map of complex
46 m = make(map[complex]complex)
47 for i := 0; i < len(s); i++ {
48 m[-a[i]] = a[i]
50 println(m[5i-5])
51 println(m[cmplx(-5, 5)])
54 func chantest(c chan complex) { c <- a[5] }