2 using System.Reflection;
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * static int test_<result>_<name> ();
11 * where <result> is an integer (the value that needs to be returned by
12 * the method to make it pass.
13 * <name> is a user-displayed name used to identify the test.
15 * The tests can be driven in two ways:
16 * *) running the program directly: Main() uses reflection to find and invoke
17 * the test methods (this is useful mostly to check that the tests are correct)
18 * *) with the --regression switch of the jit (this is the preferred way since
19 * all the tests will be run with optimizations on and off)
21 * The reflection logic could be moved to a .dll since we need at least another
22 * regression test file written in IL code to have better control on how
29 return TestDriver.RunTests (typeof (Tests));
32 static int test_0_catch () {
33 Exception x = new Exception ();
37 } catch (Exception e) {
44 static int test_0_finally_without_exc () {
49 } catch (Exception e) {
58 static int test_0_finally () {
62 throw new Exception ();
63 } catch (Exception e) {
71 static int test_0_byte_cast () {
83 } catch (OverflowException) {
95 } catch (OverflowException) {
107 } catch (OverflowException) {
119 } catch (OverflowException) {
131 } catch (OverflowException) {
143 } catch (OverflowException) {
155 } catch (OverflowException) {
168 } catch (OverflowException) {
180 } catch (OverflowException) {
192 } catch (OverflowException) {
204 } catch (OverflowException) {
216 } catch (OverflowException) {
225 static int test_0_sbyte_cast () {
237 } catch (OverflowException) {
249 } catch (OverflowException) {
261 } catch (OverflowException) {
273 } catch (OverflowException) {
285 } catch (OverflowException) {
297 } catch (OverflowException) {
309 } catch (OverflowException) {
321 } catch (OverflowException) {
333 } catch (OverflowException) {
345 } catch (OverflowException) {
357 } catch (OverflowException) {
369 } catch (OverflowException) {
381 } catch (OverflowException) {
393 } catch (OverflowException) {
405 } catch (OverflowException) {
417 } catch (OverflowException) {
429 } catch (OverflowException) {
441 } catch (OverflowException) {
453 } catch (OverflowException) {
465 } catch (OverflowException) {
474 static int test_0_ushort_cast () {
481 a = System.UInt16.MaxValue;
486 } catch (OverflowException) {
498 } catch (OverflowException) {
505 a = System.UInt16.MaxValue + 1;
510 } catch (OverflowException) {
522 } catch (OverflowException) {
534 } catch (OverflowException) {
541 double d = System.UInt16.MaxValue;
546 } catch (OverflowException) {
558 } catch (OverflowException) {
565 double d = System.UInt16.MaxValue + 1.0;
570 } catch (OverflowException) {
577 l = System.UInt16.MaxValue;
582 } catch (OverflowException) {
594 } catch (OverflowException) {
601 l = System.UInt16.MaxValue + 1;
606 } catch (OverflowException) {
618 } catch (OverflowException) {
627 static int test_0_short_cast () {
634 a = System.UInt16.MaxValue;
639 } catch (OverflowException) {
651 } catch (OverflowException) {
658 a = System.Int16.MaxValue + 1;
663 } catch (OverflowException) {
670 a = System.Int16.MinValue - 1;
675 } catch (OverflowException) {
687 } catch (OverflowException) {
694 a = System.Int16.MinValue;
699 } catch (OverflowException) {
706 a = System.Int16.MaxValue;
711 } catch (OverflowException) {
718 a = System.Int16.MaxValue + 1;
723 } catch (OverflowException) {
730 double d = System.Int16.MaxValue;
735 } catch (OverflowException) {
742 double d = System.Int16.MinValue;
747 } catch (OverflowException) {
754 double d = System.Int16.MaxValue + 1.0;
759 } catch (OverflowException) {
766 double d = System.Int16.MinValue - 1.0;
771 } catch (OverflowException) {
778 l = System.Int16.MaxValue + 1;
783 } catch (OverflowException) {
790 l = System.Int16.MaxValue;
795 } catch (OverflowException) {
802 l = System.Int16.MinValue - 1;
807 } catch (OverflowException) {
815 l = System.Int16.MinValue;
820 } catch (OverflowException) {
829 static int test_0_int_cast () {
835 double d = System.Int32.MaxValue + 1.0;
840 } catch (OverflowException) {
847 double d = System.Int32.MaxValue;
852 } catch (OverflowException) {
860 double d = System.Int32.MinValue;
865 } catch (OverflowException) {
873 double d = System.Int32.MinValue - 1.0;
878 } catch (OverflowException) {
885 l = System.Int32.MaxValue + (long)1;
890 } catch (OverflowException) {
897 l = System.Int32.MaxValue;
902 } catch (OverflowException) {
910 l = System.Int32.MinValue;
915 } catch (OverflowException) {
923 l = System.Int32.MinValue - (long)1;
928 } catch (OverflowException) {
937 static int test_0_uint_cast () {
943 double d = System.UInt32.MaxValue;
948 } catch (OverflowException) {
955 double d = System.UInt32.MaxValue + 1.0;
960 } catch (OverflowException) {
967 double d = System.UInt32.MinValue;
972 } catch (OverflowException) {
979 double d = System.UInt32.MinValue - 1.0;
984 } catch (OverflowException) {
991 l = System.UInt32.MaxValue;
996 } catch (OverflowException) {
1003 l = System.UInt32.MaxValue + (long)1;
1008 } catch (OverflowException) {
1015 l = System.UInt32.MinValue;
1020 } catch (OverflowException) {
1027 l = System.UInt32.MinValue - (long)1;
1032 } catch (OverflowException) {
1041 static int test_0_long_cast () {
1046 double d = System.Int64.MaxValue - 512.0;
1051 } catch (OverflowException) {
1058 double d = System.Int64.MaxValue - 513.0;
1063 } catch (OverflowException) {
1071 double d = System.Int64.MinValue - 1024.0;
1076 } catch (OverflowException) {
1083 double d = System.Int64.MinValue - 1025.0;
1088 } catch (OverflowException) {
1097 static int test_0_ulong_cast () {
1102 double d = System.UInt64.MaxValue - 1024.0;
1107 } catch (OverflowException) {
1114 double d = System.UInt64.MaxValue - 1025.0;
1119 } catch (OverflowException) {
1132 } catch (OverflowException) {
1144 } catch (OverflowException) {
1153 static int test_0_simple_double_casts () {
1155 double d = 0xffffffff;
1157 if ((uint)d != 4294967295)
1160 d = 0xffffffffffffffff;
1173 if ((ushort)d != 0xffff)
1176 if ((byte)d != 0xff)
1182 static int test_0_div_zero () {
1191 } catch (DivideByZeroException) {
1200 } catch (DivideByZeroException) {
1209 static int test_0_udiv_zero () {
1218 } catch (DivideByZeroException) {
1227 } catch (DivideByZeroException) {
1236 static int test_0_long_div_zero () {
1245 } catch (DivideByZeroException) {
1254 } catch (DivideByZeroException) {
1263 static int test_0_ulong_div_zero () {
1272 } catch (DivideByZeroException) {
1281 } catch (DivideByZeroException) {
1290 static int test_0_float_div_zero () {
1299 } catch (DivideByZeroException) {
1308 } catch (DivideByZeroException) {