...
1
2
3
4
5
6
7 package conversions
8
9 import "unsafe"
10
11
12 var (
13 _ = int()
14 _ = int(1, 2 )
15 )
16
17
18
19 func string_conversions() {
20 const A = string(65)
21 assert(A == "A")
22 const E = string(-1)
23 assert(E == "\uFFFD")
24 assert(E == string(1234567890))
25
26 type myint int
27 assert(A == string(myint(65)))
28
29 type mystring string
30 const _ mystring = mystring("foo")
31
32 const _ = string(true )
33 const _ = string(1.2 )
34 const _ = string(nil )
35
36
37 _ = string(0.0 )
38 _ = string(0i )
39 _ = string(1 + 2i)
40 }
41
42 func interface_conversions() {
43 type E interface{}
44
45 type I1 interface{
46 m1()
47 }
48
49 type I2 interface{
50 m1()
51 m2(x int)
52 }
53
54 type I3 interface{
55 m1()
56 m2() int
57 }
58
59 var e E
60 var i1 I1
61 var i2 I2
62 var i3 I3
63
64 _ = E(0)
65 _ = E(nil)
66 _ = E(e)
67 _ = E(i1)
68 _ = E(i2)
69
70 _ = I1(0 )
71 _ = I1(nil)
72 _ = I1(i1)
73 _ = I1(e )
74 _ = I1(i2)
75
76 _ = I2(nil)
77 _ = I2(i1 )
78 _ = I2(i2)
79 _ = I2(i3 )
80
81 _ = I3(nil)
82 _ = I3(i1 )
83 _ = I3(i2 )
84 _ = I3(i3)
85
86
87 }
88
89 func issue6326() {
90 type T unsafe.Pointer
91 var x T
92 _ = uintptr(x)
93 }
94
View as plain text