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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [named1.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// errchk $G -e $D/$F.go
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
// Test that basic operations on named types are valid
8
// and preserve the type.
9
 
10
package main
11
 
12
type Bool bool
13
 
14
type Map map[int]int
15
 
16
func (Map) M() {}
17
 
18
type Slice []byte
19
 
20
var slice Slice
21
 
22
func asBool(Bool)     {}
23
func asString(String) {}
24
 
25
type String string
26
 
27
func main() {
28
        var (
29
                b    Bool = true
30
                i, j int
31
                c    = make(chan int)
32
                m    = make(Map)
33
        )
34
 
35
        asBool(b)
36
        asBool(!b)
37
        asBool(true)
38
        asBool(*&b)
39
        asBool(Bool(true))
40
        asBool(1 != 2) // ERROR "cannot use.*type bool.*as type Bool"
41
        asBool(i < j)  // ERROR "cannot use.*type bool.*as type Bool"
42
 
43
        _, b = m[2] // ERROR "cannot .* bool.*type Bool"
44
 
45
        var inter interface{}
46
        _, b = inter.(Map) // ERROR "cannot .* bool.*type Bool"
47
        _ = b
48
 
49
        var minter interface {
50
                M()
51
        }
52
        _, b = minter.(Map) // ERROR "cannot .* bool.*type Bool"
53
        _ = b
54
 
55
        _, bb := <-c
56
        asBool(bb) // ERROR "cannot use.*type bool.*as type Bool"
57
        _, b = <-c // ERROR "cannot .* bool.*type Bool"
58
        _ = b
59
 
60
        asString(String(slice)) // ok
61
}

powered by: WebSVN 2.1.0

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