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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [robfunc.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 2009 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
func assertequal(is, shouldbe int, msg string) {
10
        if is != shouldbe {
11
                print("assertion fail" + msg + "\n")
12
                panic(1)
13
        }
14
}
15
 
16
func f1() {
17
}
18
 
19
func f2(a int) {
20
}
21
 
22
func f3(a, b int) int {
23
        return a + b
24
}
25
 
26
func f4(a, b int, c float64) int {
27
        return (a+b)/2 + int(c)
28
}
29
 
30
func f5(a int) int {
31
        return 5
32
}
33
 
34
func f6(a int) (r int) {
35
        return 6
36
}
37
 
38
func f7(a int) (x int, y float64) {
39
        return 7, 7.0
40
}
41
 
42
 
43
func f8(a int) (x int, y float64) {
44
        return 8, 8.0
45
}
46
 
47
type T struct {
48
        x, y int
49
}
50
 
51
func (t *T) m10(a int, b float64) int {
52
        return (t.x + a) * (t.y + int(b))
53
}
54
 
55
 
56
func f9(a int) (in int, fl float64) {
57
        i := 9
58
        f := float64(9)
59
        return i, f
60
}
61
 
62
 
63
func main() {
64
        f1()
65
        f2(1)
66
        r3 := f3(1, 2)
67
        assertequal(r3, 3, "3")
68
        r4 := f4(0, 2, 3.0)
69
        assertequal(r4, 4, "4")
70
        r5 := f5(1)
71
        assertequal(r5, 5, "5")
72
        r6 := f6(1)
73
        assertequal(r6, 6, "6")
74
        var r7 int
75
        var s7 float64
76
        r7, s7 = f7(1)
77
        assertequal(r7, 7, "r7")
78
        assertequal(int(s7), 7, "s7")
79
        var r8 int
80
        var s8 float64
81
        r8, s8 = f8(1)
82
        assertequal(r8, 8, "r8")
83
        assertequal(int(s8), 8, "s8")
84
        var r9 int
85
        var s9 float64
86
        r9, s9 = f9(1)
87
        assertequal(r9, 9, "r9")
88
        assertequal(int(s9), 9, "s9")
89
        var t *T = new(T)
90
        t.x = 1
91
        t.y = 2
92
        r10 := t.m10(1, 3.0)
93
        assertequal(r10, 10, "10")
94
}

powered by: WebSVN 2.1.0

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