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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [ken/] [intervar.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
type    Iputs   interface {
10
        puts    (s string) string;
11
}
12
 
13
// ---------
14
 
15
type    Print   struct {
16
        whoami  int;
17
        put     Iputs;
18
}
19
 
20
func (p *Print) dop() string {
21
        r := " print " + string(p.whoami + '0')
22
        return r + p.put.puts("abc");
23
}
24
 
25
// ---------
26
 
27
type    Bio     struct {
28
        whoami  int;
29
        put     Iputs;
30
}
31
 
32
func (b *Bio) puts(s string) string {
33
        r := " bio " + string(b.whoami + '0')
34
        return r + b.put.puts(s);
35
}
36
 
37
// ---------
38
 
39
type    File    struct {
40
        whoami  int;
41
        put     Iputs;
42
}
43
 
44
func (f *File) puts(s string) string {
45
        return " file " + string(f.whoami + '0') + " -- " + s
46
}
47
 
48
func
49
main() {
50
        p := new(Print);
51
        b := new(Bio);
52
        f := new(File);
53
 
54
        p.whoami = 1;
55
        p.put = b;
56
 
57
        b.whoami = 2;
58
        b.put = f;
59
 
60
        f.whoami = 3;
61
 
62
        r := p.dop();
63
        expected := " print 1 bio 2 file 3 -- abc"
64
        if r != expected {
65
                panic(r + " != " + expected)
66
        }
67
}

powered by: WebSVN 2.1.0

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