]> Cypherpunks.ru repositories - gostls13.git/blob - test/convert.go
make 6g constants behave as ken proposes. (i hope.)
[gostls13.git] / test / convert.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
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 "unsafe"
10
11 func typeof(x interface{}) string {
12         val, typ, indir := sys.Reflect(x);
13         return typ;
14 }
15
16 func f() int {
17         return 0;
18 }
19
20 func g() int {
21         return 0;
22 }
23
24 type T func() int
25
26 var m = map[string] T {
27         "f": f
28 }
29
30 type A int
31 type B int
32
33 var a A = 1;
34 var b B = 2;
35 var x int;
36
37 func main() {
38         want := typeof(g);
39         if t := typeof(f); t != want {
40                 panicln("type of f is", t, "want", want);
41         }
42
43         want = typeof(x);
44         if t := typeof(+a); t != want {
45                 panicln("type of +a is", t, "want", want);
46         }
47         if t := typeof(a+0); t != want {
48                 panicln("type of a+0 is", t, "want", want);
49         }
50         if t := typeof(a+b); t != want {
51                 panicln("type of a+b is", t, "want", want);
52         }
53 }