Prechádzať zdrojové kódy

Add test for integer suffixes

svn path=/trunk/mcs/; revision=1597
Miguel de Icaza 24 rokov pred
rodič
commit
e1da975cc5
2 zmenil súbory, kde vykonal 90 pridanie a 1 odobranie
  1. 1 1
      mcs/tests/makefile
  2. 89 0
      mcs/tests/test-59.cs

+ 1 - 1
mcs/tests/makefile

@@ -10,7 +10,7 @@ TEST_SOURCES = \
 	test-21 test-22 test-23 test-24 test-25 test-26 test-27 test-28 	test-30	\
 	test-31 test-32 test-33 test-34 test-35 test-36	test-37 	test-39 test-40 \
 	test-41 test-42 test-43 test-44 test-45 test-46 test-47 test-48 test-49 test-50 \
-	        test-52	test-53 test-54 test-55
+	        test-52	test-53 test-54 test-55 			test-59
 
 
 TEST_NOPASS = \

+ 89 - 0
mcs/tests/test-59.cs

@@ -0,0 +1,89 @@
+//
+// Tests the varios type conversions.
+//
+using System;
+
+class X {
+
+	static int test_explicit ()
+	{
+		object x_int = 1;
+		object x_uint_1 = 1u;
+		object x_uint_2 = 1U;
+		object x_long_1 = 1l;
+		object x_long_2 = 1L;
+		object x_ulong_1 = 1ul;
+		object x_ulong_2 = 1UL;
+		object x_ulong_3 = 1lu;
+		object x_ulong_4 = 1Lu;
+		object x_ulong_5 = 1LU;
+
+		if (!(x_int is int))
+			return 1;
+
+		if (!(x_uint_1 is uint))
+			return 2;
+
+		if (!(x_uint_2 is uint))
+			return 3;
+
+		if (!(x_long_1 is long))
+			return 5;
+
+		if (!(x_long_2 is long))
+			return 6;
+
+		if (!(x_ulong_1 is ulong))
+			return 7;
+
+		if (!(x_ulong_2 is ulong))
+			return 8;
+		
+		if (!(x_ulong_3 is ulong))
+			return 9;
+
+		if (!(x_ulong_4 is ulong))
+			return 10;
+
+		if (!(x_ulong_5 is ulong))
+			return 11;
+
+		return 0;
+
+	}
+
+	static int test_implicit ()
+	{
+		object i_int = 1;
+		object i_uint = 0x80000000;
+		object i_long = 0x100000000;
+		object i_ulong = 0x8000000000000000;
+
+		if (!(i_int is int))
+			return 1;
+		if (!(i_uint is uint))
+			return 2;
+		if (!(i_long is long))
+			return 3;
+		if (!(i_ulong is ulong))
+			return 4;
+
+		return 0;
+	}
+	
+	static int Main ()
+	{
+		int v;
+		v = test_explicit ();
+
+		if (v != 0)
+			return v;
+
+		v = test_implicit ();
+		if (v != 0)
+			return 20 + v;
+
+		Console.WriteLine ("Tests pass");
+		return 0;
+	}
+}