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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug113.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 I interface{}
10
 
11
func foo1(i int) int     { return i }
12
func foo2(i int32) int32 { return i }
13
func main() {
14
        var i I
15
        i = 1
16
        var v1 = i.(int)
17
        if foo1(v1) != 1 {
18
                panic(1)
19
        }
20
        var v2 = int32(i.(int))
21
        if foo2(v2) != 1 {
22
                panic(2)
23
        }
24
 
25
        shouldPanic(p1)
26
}
27
 
28
func p1() {
29
        var i I
30
        i = 1
31
        var v3 = i.(int32) // This type conversion should fail at runtime.
32
        if foo2(v3) != 1 {
33
                panic(3)
34
        }
35
}
36
 
37
func shouldPanic(f func()) {
38
        defer func() {
39
                if recover() == nil {
40
                        panic("function should panic")
41
                }
42
        }()
43
        f()
44
}

powered by: WebSVN 2.1.0

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