2010-05-31 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-59.cs
blobf509b02053c4d1168ef4e95bb050d08c5f59a36d
1 //
2 // Tests the varios type conversions.
3 //
4 using System;
6 class X {
8 static int test_explicit ()
10 object x_int = 1;
11 object x_uint_1 = 1u;
12 object x_uint_2 = 1U;
13 object x_long_1 = 1l;
14 object x_long_2 = 1L;
15 object x_ulong_1 = 1ul;
16 object x_ulong_2 = 1UL;
17 object x_ulong_3 = 1lu;
18 object x_ulong_4 = 1Lu;
19 object x_ulong_5 = 1LU;
21 if (!(x_int is int))
22 return 1;
24 if (!(x_uint_1 is uint))
25 return 2;
27 if (!(x_uint_2 is uint))
28 return 3;
30 if (!(x_long_1 is long))
31 return 5;
33 if (!(x_long_2 is long))
34 return 6;
36 if (!(x_ulong_1 is ulong))
37 return 7;
39 if (!(x_ulong_2 is ulong))
40 return 8;
42 if (!(x_ulong_3 is ulong))
43 return 9;
45 if (!(x_ulong_4 is ulong))
46 return 10;
48 if (!(x_ulong_5 is ulong))
49 return 11;
51 return 0;
55 static int test_implicit ()
57 object i_int = 1;
58 object i_uint = 0x80000000;
59 object i_long = 0x100000000;
60 object i_ulong = 0x8000000000000000;
62 if (!(i_int is int))
63 return 1;
64 if (!(i_uint is uint))
65 return 2;
66 if (!(i_long is long))
67 return 3;
68 if (!(i_ulong is ulong))
69 return 4;
71 return 0;
74 static int Main ()
76 int v;
77 v = test_explicit ();
79 if (v != 0)
80 return v;
82 v = test_implicit ();
83 if (v != 0)
84 return 20 + v;
87 // Just a compilation fix: 21418
89 ulong l = 1;
90 if (l != 0L)
94 // This was a compilation bug, error: 57522
95 ulong myulog = 0L;
97 Console.WriteLine ("Tests pass");
98 return 0;