OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [cplx5.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $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
var a [12]complex128
10
var s []complex128
11
var c chan complex128
12
var f struct {
13
        c complex128
14
}
15
var m map[complex128]complex128
16
 
17
func main() {
18
        // array of complex128
19
        for i := 0; i < len(a); i++ {
20
                a[i] = complex(float64(i), float64(-i))
21
        }
22
        if a[5] != 5-5i {
23
                panic(a[5])
24
        }
25
 
26
        // slice of complex128
27
        s = make([]complex128, len(a))
28
        for i := 0; i < len(s); i++ {
29
                s[i] = a[i]
30
        }
31
        if s[5] != 5-5i {
32
                panic(s[5])
33
        }
34
 
35
        // chan
36
        c = make(chan complex128)
37
        go chantest(c)
38
        vc := <-c
39
        if vc != 5-5i {
40
                panic(vc)
41
        }
42
 
43
        // pointer of complex128
44
        v := a[5]
45
        pv := &v
46
        if *pv != 5-5i {
47
                panic(*pv)
48
        }
49
 
50
        // field of complex128
51
        f.c = a[5]
52
        if f.c != 5-5i {
53
                panic(f.c)
54
        }
55
 
56
        // map of complex128
57
        m = make(map[complex128]complex128)
58
        for i := 0; i < len(s); i++ {
59
                m[-a[i]] = a[i]
60
        }
61
        if m[5i-5] != 5-5i {
62
                panic(m[5i-5])
63
        }
64
        vm := m[complex(-5, 5)]
65
        if vm != 5-5i {
66
                panic(vm)
67
        }
68
}
69
 
70
func chantest(c chan complex128) { c <- a[5] }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.