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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [interface/] [noeq.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 || echo BUG: interface/noeq
2
 
3
// Copyright 2011 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
// Interface values containing types that cannot be compared for equality.
8
 
9
package main
10
 
11
func main() {
12
        cmp(1)
13
 
14
        var (
15
                m map[int]int
16
                s struct{ x []int }
17
                f func()
18
        )
19
        noCmp(m)
20
        noCmp(s)
21
        noCmp(f)
22
}
23
 
24
func cmp(x interface{}) bool {
25
        return x == x
26
}
27
 
28
func noCmp(x interface{}) {
29
        shouldPanic(func() { cmp(x) })
30
}
31
 
32
func shouldPanic(f func()) {
33
        defer func() {
34
                if recover() == nil {
35
                        panic("function should panic")
36
                }
37
        }()
38
        f()
39
}

powered by: WebSVN 2.1.0

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