Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-10.cs
1 /*
2  * Test explicit numeric conversions.
3  */
4
5 using System;
6
7 class X {
8
9         void asbyte (byte a, ushort b, uint c, ulong d, char e)
10         {
11         }
12
13         void bsbyte ()
14         {
15                 sbyte s = 0;
16
17                 asbyte ((byte) s, (ushort) s, (uint) s, (ulong) s, (char) s);
18                 asbyte (checked ((byte) s), checked ((ushort) s), checked ((uint) s), checked ((ulong) s), checked ((char) s));
19         }
20
21         void abyte (sbyte a, char b)
22         {
23         }
24
25         void bbyte ()
26         {
27                 byte b = 0;
28
29                 abyte ((sbyte) b, (char) b);
30                 abyte (checked ((sbyte) b), checked ((char) b));
31         }
32
33         void ashort (sbyte a, byte b, ushort c, uint d, ulong e, char f)
34         {
35         }
36
37         void bshort ()
38         {
39                 short a = 1;
40
41                 ashort ((sbyte) a, (byte) a, (ushort) a, (uint) a, (ulong) a, (char) a);
42                 ashort (checked ((sbyte) a), checked ((byte) a), checked ((ushort) a), checked ((uint) a), checked ((ulong) a), checked ((char) a));
43         }
44
45         void aushort (sbyte a, byte b, short c, char d)
46         {
47         }
48
49         void bushort ()
50         {
51                 ushort a = 1;
52                 aushort ((sbyte) a, (byte) a, (short) a, (char) a);
53                 aushort (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((char) a));
54         }
55
56         void aint (sbyte a, byte b, short c, ushort d, uint e, ulong f, char g)
57         {
58         }
59
60         void bint ()
61         {
62                 int a = 1;
63
64                 aint ((sbyte) a, (byte) a, (short) a, (ushort) a, (uint) a, (ulong) a, (char) a);
65                 aint (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((uint) a), checked ((ulong) a), checked ((char) a));
66         }
67
68         void auint (sbyte a, byte b, short c, ushort d, int e, char f)
69         {
70         }
71
72         void buint ()
73         {
74                 uint a = 1;
75
76                 auint ((sbyte) a, (byte) a, (short) a, (ushort) a, (int) a, (char) a);
77                 auint (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((int) a), checked ((char) a));
78         }
79
80         void along (sbyte a, byte b, short c, ushort d, int e, uint f, ulong g, char h)
81         {
82         }
83
84         void blong ()
85         {
86                 long a = 1;
87
88                 along ((sbyte) a, (byte) a, (short) a, (ushort) a, (int) a, (uint) a, (ulong) a, (char) a);
89                 along (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((int) a), checked ((uint) a), checked ((ulong) a), checked ((char) a));
90         }
91
92         void aulong (sbyte a, byte b, short c, ushort d, int e, uint f, long g, char h)
93         {
94         }
95
96         void bulong ()
97         {
98                 ulong a = 1;
99
100                 aulong ((sbyte) a, (byte) a, (short) a, (ushort) a, (int) a, (uint) a, (long) a, (char) a);
101                 aulong (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((int) a), checked ((uint) a), checked ((long) a), checked ((char) a));
102         }
103
104         void achar (sbyte a, byte b, short c)
105         {
106
107         }
108
109         void bchar ()
110         {
111                 char a = (char) 1;
112
113                 achar ((sbyte) a, (byte) a, (short) a);
114                 achar (checked ((sbyte) a), checked ((byte) a), checked ((short) a));
115         }
116
117         void afloat (sbyte a, byte b, short c, ushort d, int e, uint f, long ll, ulong g, char h, decimal dd)
118         {
119         }
120
121         void bfloat ()
122         {
123                 float a = 1;
124
125                 afloat ((sbyte) a, (byte) a, (short) a, (ushort) a, (int) a, (uint) a, (long) a,
126                         (ulong) a, (char) a, (decimal) a);
127                 afloat (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((int) a), checked ((uint) a), checked ((long) a),
128 checked (                       (ulong) a), checked ((char) a), checked ((decimal) a));
129         }
130
131         void adouble (sbyte a, byte b, short c, ushort d, int e, uint f, long ll, ulong g, char h,
132                       float ff, decimal dd)
133         {
134         }
135         
136         void bdouble ()
137         {
138                 double a = 1;
139
140                 adouble ((sbyte) a, (byte) a, (short) a, (ushort) a, (int) a, (uint) a, (long) a,
141                         (ulong) a, (char) a, (float) a, (decimal) a);
142                 adouble (checked ((sbyte) a), checked ((byte) a), checked ((short) a), checked ((ushort) a), checked ((int) a), checked ((uint) a), checked ((long) a),
143 checked (                       (ulong) a), checked ((char) a), checked ((float) a), (decimal) a);
144         }
145         
146         void TestDecimal (decimal d)
147         {
148                 double dec = (double)d;
149                 decimal dec2 = (decimal)dec;
150         }
151         
152         public static void Main ()
153         {
154
155         }
156 }
157
158 enum E:byte {
159         Min = 9
160 }
161
162 class Test2 {
163         void ExtraTst ()
164         {
165                 E error = E.Min - 9;
166                 string s = (string)null;
167                 const decimal d = -10.1m;
168                 const long l = (long)d;
169                 char ch = (char)E.Min;
170                 bool b = (DBNull) null == null;
171         }
172 }