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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [alias1.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 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
package main
8
 
9
// Test that dynamic interface checks treat byte=uint8
10
// and rune=int or rune=int32.
11
 
12
func main() {
13
        var x interface{}
14
 
15
        x = byte(1)
16
        switch x.(type) {
17
        case uint8:
18
                // ok
19
        default:
20
                println("byte != uint8")
21
        }
22
 
23
        x = uint8(2)
24
        switch x.(type) {
25
        case byte:
26
                // ok
27
        default:
28
                println("uint8 != byte")
29
        }
30
 
31
        rune32 := false
32
        x = rune(3)
33
        switch x.(type) {
34
        case int:
35
                // ok
36
        case int32:
37
                // must be new code
38
                rune32 = true
39
        default:
40
                println("rune != int and rune != int32")
41
        }
42
 
43
        if rune32 {
44
                x = int32(4)
45
        } else {
46
                x = int(5)
47
        }
48
        switch x.(type) {
49
        case rune:
50
                // ok
51
        default:
52
                println("int (or int32) != rune")
53
        }
54
}

powered by: WebSVN 2.1.0

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