X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Farrays.cs;h=00a3c6b901f86a6b0c92e4b9a2993dbb447f3e78;hb=22187e8df1ef41c523debc94137f6f660cb0e422;hp=67a35426e290547fa612bd3164cf56abda8dce7b;hpb=0880d632f919feab995ecfdff6b810abfeb0793d;p=mono.git diff --git a/mono/mini/arrays.cs b/mono/mini/arrays.cs index 67a35426e29..00a3c6b901f 100644 --- a/mono/mini/arrays.cs +++ b/mono/mini/arrays.cs @@ -23,11 +23,18 @@ using System.Reflection; * the IL code looks. */ -class Tests { - - static int Main () { - return TestDriver.RunTests (typeof (Tests)); - } +#if __MOBILE__ +class ArrayTests +#else +class Tests +#endif +{ + +#if !__MOBILE__ + public static int Main (string[] args) { + return TestDriver.RunTests (typeof (Tests), args); + } +#endif public static int test_10_create () { int[] a = new int [10]; @@ -101,30 +108,31 @@ class Tests { return 0; } - private Int32[] m_array = new int [10]; - - void setBit (int bitIndex, bool value) { - int index = bitIndex/32; - int shift = bitIndex%32; + class BitClass { + private Int32[] m_array = new int [10]; - Int32 theBit = 1 << shift; - if (value) - m_array[index] |= theBit; - else - m_array[index] &= ~theBit; - } - - bool getBit (int bitIndex) { - int index = bitIndex/32; - int shift = bitIndex%32; + public void setBit (int bitIndex, bool value) { + int index = bitIndex/32; + int shift = bitIndex%32; - Int32 theBit = m_array[index] & (1 << shift); - return (theBit == 0) ? false : true; + Int32 theBit = 1 << shift; + if (value) + m_array[index] |= theBit; + else + m_array[index] &= ~theBit; + } + + public bool getBit (int bitIndex) { + int index = bitIndex/32; + int shift = bitIndex%32; + Int32 theBit = m_array[index] & (1 << shift); + return (theBit == 0) ? false : true; + } } public static int test_1_bit_index () { - Tests t = new Tests (); + var t = new BitClass (); t.setBit (0, true); t.setBit (3, true); if (t.getBit (1)) @@ -452,6 +460,13 @@ class Tests { return test [1, 1, 1]; } + public static int test_100_4_dimensional_arrays () { + int[,,,] test = new int[10, 10, 10, 10]; + + test [1, 1, 1, 1] = 100; + return test [1, 1, 1, 1]; + } + public static int test_0_bug_71454 () { int[,] a = new int[4,4]; int[,] b = new int[4,4]; @@ -492,10 +507,13 @@ class Tests { return y; } + class RefClass { + } + public static int test_0_stelem_ref_null_opt () { - object[] arr = new Tests [1]; + object[] arr = new RefClass [1]; - arr [0] = new Tests (); + arr [0] = new RefClass (); arr [0] = null; return arr [0] == null ? 0 : 1; @@ -748,7 +766,46 @@ class Tests { test[x+100,y+100] = true; } return 0; - } + } + + static bool alloc_long (long l) { + try { + var arr = new byte[l]; + return false; + } catch (Exception e) { + return true; + } + } + + // #13544 + public static int test_0_newarr_ovf () { + if (!alloc_long (5000000000)) + return 1; + if (!alloc_long (4000000000)) + return 2; + if (!alloc_long (-1)) + return 3; + if (!alloc_long (-4000000000)) + return 4; + if (!alloc_long (-6000000000)) + return 5; + return 0; + } + + static int llvm_ldlen_licm (int[] arr) { + int sum = 0; + // The ldlen should be moved out of the loop + for (int i = 0; i < arr.Length; ++i) + sum += arr [i]; + return sum; + } + + public static int test_10_llvm_ldlen_licm () { + int[] arr = new int [10]; + for (int i = 0; i < 10; ++i) + arr [i] = 1; + return llvm_ldlen_licm (arr); + } }