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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [interface/] [embed.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
// Check methods derived from embedded interface values.
8
 
9
package main
10
 
11
import "os"
12
 
13
const Value = 1e12
14
 
15
type Inter interface { M() int64 }
16
 
17
type T int64
18
func (t T) M() int64 { return int64(t) }
19
var t = T(Value)
20
var pt = &t
21
var ti Inter = t
22
 
23
type S struct { Inter }
24
var s = S{ ti }
25
var ps = &s
26
 
27
var i Inter
28
 
29
var ok = true
30
 
31
func check(s string, v int64) {
32
        if v != Value {
33
                println(s, v)
34
                ok = false
35
        }
36
}
37
 
38
func main() {
39
        check("t.M()", t.M())
40
        check("pt.M()", pt.M())
41
        check("ti.M()", ti.M())
42
        check("s.M()", s.M())
43
        check("ps.M()", ps.M())
44
 
45
        i = t
46
        check("i = t; i.M()", i.M())
47
 
48
        i = pt
49
        check("i = pt; i.M()", i.M())
50
 
51
        i = s
52
        check("i = s; i.M()", i.M())
53
 
54
        i = ps
55
        check("i = ps; i.M()", i.M())
56
 
57
        if !ok {
58
                println("BUG: interface10")
59
                os.Exit(1)
60
        }
61
}

powered by: WebSVN 2.1.0

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