]> Cypherpunks.ru repositories - gostls13.git/blob - test/convert.go
test: use testlib (first 100)
[gostls13.git] / test / convert.go
1 // run
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 import "reflect"
10
11 func typeof(x interface{}) string { return reflect.TypeOf(x).String() }
12
13 func f() int { return 0 }
14
15 func g() int { return 0 }
16
17 type T func() int
18
19 var m = map[string]T{"f": f}
20
21 type A int
22 type B int
23
24 var a A = 1
25 var b B = 2
26 var x int
27
28 func main() {
29         want := typeof(g)
30         if t := typeof(f); t != want {
31                 println("type of f is", t, "want", want)
32                 panic("fail")
33         }
34
35         want = typeof(a)
36         if t := typeof(+a); t != want {
37                 println("type of +a is", t, "want", want)
38                 panic("fail")
39         }
40         if t := typeof(a + 0); t != want {
41                 println("type of a+0 is", t, "want", want)
42                 panic("fail")
43         }
44 }