]> Cypherpunks.ru repositories - gostls13.git/blob - test/switch3.go
test: use testlib (final 61)
[gostls13.git] / test / switch3.go
1 // errorcheck
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 type I interface {
10         M()
11 }
12
13 func bad() {
14         var i I
15         var s string
16
17         switch i {
18         case s: // ERROR "mismatched types string and I|incompatible types"
19         }
20
21         switch s {
22         case i: // ERROR "mismatched types I and string|incompatible types"
23         }
24
25         var m, m1 map[int]int
26         switch m {
27         case nil:
28         case m1: // ERROR "can only compare map m to nil|map can only be compared to nil"
29         default:
30         }
31
32         var a, a1 []int
33         switch a {
34         case nil:
35         case a1: // ERROR "can only compare slice a to nil|slice can only be compared to nil"
36         default:
37         }
38
39         var f, f1 func()
40         switch f {
41         case nil:
42         case f1: // ERROR "can only compare func f to nil|func can only be compared to nil"
43         default:
44         }
45 }
46
47 func good() {
48         var i interface{}
49         var s string
50
51         switch i {
52         case s:
53         }
54
55         switch s {
56         case i:
57         }
58 }