Author: zoltan
Date: 2008-02-03 12:35:30 -0500 (Sun, 03 Feb 2008)
New Revision: 94703

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/generics-variant-types.2.il
   trunk/mono/mono/mini/generics.2.cs
Log:
2008-02-03  Zoltan Varga  <[EMAIL PROTECTED]>

        * generics.2.cs generics-variant-types.2.il: Merge some tests from the 
linear IR
        branch.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2008-02-03 17:33:27 UTC (rev 94702)
+++ trunk/mono/mono/mini/ChangeLog      2008-02-03 17:35:30 UTC (rev 94703)
@@ -1,3 +1,8 @@
+2008-02-03  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * generics.2.cs generics-variant-types.2.il: Merge some tests from the 
linear IR
+       branch.
+
 2008-01-31  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * objects.cs: Add some soft-float tests.

Modified: trunk/mono/mono/mini/generics-variant-types.2.il
===================================================================
--- trunk/mono/mono/mini/generics-variant-types.2.il    2008-02-03 17:33:27 UTC 
(rev 94702)
+++ trunk/mono/mono/mini/generics-variant-types.2.il    2008-02-03 17:35:30 UTC 
(rev 94703)
@@ -21,7 +21,7 @@
 //
 // A Covariant interface
 //
-.class interface public abstract auto ansi beforefieldinit IEnumerator`1<+T>
+.class interface public abstract auto ansi beforefieldinit MyIEnumerator`1<+T>
 {
        .method public hidebysig abstract virtual instance bool  MoveNext() cil 
managed
        {
@@ -33,7 +33,7 @@
        
        .property !T Current()
        {
-       .get instance !T IEnumerator`1::get_Current()
+       .get instance !T MyIEnumerator`1::get_Current()
        }
 }
 

Modified: trunk/mono/mono/mini/generics.2.cs
===================================================================
--- trunk/mono/mono/mini/generics.2.cs  2008-02-03 17:33:27 UTC (rev 94702)
+++ trunk/mono/mono/mini/generics.2.cs  2008-02-03 17:35:30 UTC (rev 94703)
@@ -1,23 +1,26 @@
 using System;
+using System.Collections.Generic;
 
 class Tests {
 
        struct TestStruct {
                public int i;
+               public int j;
 
-               public TestStruct (int i) {
+               public TestStruct (int i, int j) {
                        this.i = i;
+                       this.j = j;
                }
        }
 
-       class Enumerator <T> : IEnumerator <T> {
-               T IEnumerator<T>.Current {
+       class Enumerator <T> : MyIEnumerator <T> {
+               T MyIEnumerator<T>.Current {
                        get {
                                return default(T);
                        }
                }
 
-               bool IEnumerator<T>.MoveNext () {
+               bool MyIEnumerator<T>.MoveNext () {
                        return true;
                }
        }
@@ -61,7 +64,7 @@
 
        public static int test_1_nullable_unbox_vtype ()
        {
-               return Unbox<TestStruct?> (new TestStruct (1)).Value.i;
+               return Unbox<TestStruct?> (new TestStruct (1, 2)).Value.i;
        }
 
        public static int test_1_nullable_unbox_null_vtype ()
@@ -71,7 +74,7 @@
 
        public static int test_1_nullable_box_vtype ()
        {
-               return ((TestStruct)(Box<TestStruct?> (new TestStruct (1)))).i;
+               return ((TestStruct)(Box<TestStruct?> (new TestStruct (1, 
2)))).i;
        }
 
        public static int test_1_nullable_box_null_vtype ()
@@ -81,10 +84,24 @@
 
        public static int test_1_isinst_nullable_vtype ()
        {
-               object o = new TestStruct (1);
+               object o = new TestStruct (1, 2);
                return (o is TestStruct?) ? 1 : 0;
        }
 
+       public static int test_0_nullable_normal_unbox ()
+       {
+               int? i = 5;
+
+               object o = i;
+               // This uses unbox instead of unbox_any
+               int? j = (int?)o;
+
+               if (j != 5)
+                       return 1;
+
+               return 0;
+       }
+
        public static void stelem_any<T> (T[] arr, T elem) {
                arr [0] = elem;
        }
@@ -118,6 +135,84 @@
                return 1;
        }
 
+       public static int test_18_ldobj_stobj_generics () {
+               GenericClass<int> t = new GenericClass <int> ();
+               int i = 5;
+               int j = 6;
+               return t.ldobj_stobj (ref i, ref j) + i + j;
+       }
+
+       public static int test_5_ldelem_stelem_generics () {
+               GenericClass<TestStruct> t = new GenericClass<TestStruct> ();
+
+               TestStruct s = new TestStruct (5, 5);
+               return t.ldelem_stelem (s).i;
+       }
+
+       public static int test_0_constrained_vtype_box () {
+               GenericClass<TestStruct> t = new GenericClass<TestStruct> ();
+
+               return t.toString (new TestStruct ()) == "Tests+TestStruct" ? 0 
: 1;
+       }
+
+       public static int test_0_constrained_vtype () {
+               GenericClass<int> t = new GenericClass<int> ();
+
+               return t.toString (1234) == "1234" ? 0 : 1;
+       }
+
+       public static int test_0_constrained_reftype () {
+               GenericClass<String> t = new GenericClass<String> ();
+
+               return t.toString ("1234") == "1234" ? 0 : 1;
+       }
+
+       public static int test_0_box_brtrue_optimizations () {
+               if (IsNull<int>(5))
+                       return 1;
+
+               if (!IsNull<object>(null))
+                       return 1;
+
+               return 0;
+       }
+
+       public static int test_0_generic_get_value_optimization_int () {
+               int[] x = new int[] {100, 200};
+
+               if (GenericClass<int>.Z (x, 0) != 100)
+                       return 2;
+
+               if (GenericClass<int>.Z (x, 1) != 200)
+                       return 3;
+
+               return 0;
+       }
+
+       public static int test_0_generic_get_value_optimization_vtype () {
+               TestStruct[] arr = new TestStruct[] { new TestStruct (100, 
200), new TestStruct (300, 400) };
+               IEnumerator<TestStruct> enumerator = GenericClass<TestStruct>.Y 
(arr);
+               TestStruct s;
+               int sum = 0;
+               while (enumerator.MoveNext ()) {
+                       s = enumerator.Current;
+                       sum += s.i + s.j;
+               }
+
+               if (sum != 1000)
+                       return 1;
+
+               s = GenericClass<TestStruct>.Z (arr, 0);
+               if (s.i != 100 || s.j != 200)
+                       return 2;
+
+               s = GenericClass<TestStruct>.Z (arr, 1);
+               if (s.i != 300 || s.j != 400)
+                       return 3;
+
+               return 0;
+       }
+
        public struct GenericStruct<T> {
                public T t;
 
@@ -132,6 +227,37 @@
                public GenericClass (T t) {
                        this.t = t;
                }
+
+               public GenericClass () {
+               }
+
+               public T ldobj_stobj (ref T t1, ref T t2) {
+                       t1 = t2;
+                       T t = t1;
+
+                       return t;
+               }
+
+               public T ldelem_stelem (T t) {
+                       T[] arr = new T [10];
+                       arr [0] = t;
+
+                       return arr [0];
+               }
+
+               public String toString (T t) {
+                       return t.ToString ();
+               }
+
+               public static IEnumerator<T> Y (IEnumerable <T> x)
+               {
+                       return x.GetEnumerator ();
+               }
+
+               public static T Z (IList<T> x, int index)
+               {
+                       return x [index];
+               }
        }
 
        public class MRO : MarshalByRefObject {
@@ -191,13 +317,13 @@
 
        public static int test_0_variance_reflection () {
                // covariance on IEnumerator
-               if (!typeof (IEnumerator<object>).IsAssignableFrom (typeof 
(IEnumerator<string>)))
+               if (!typeof (MyIEnumerator<object>).IsAssignableFrom (typeof 
(MyIEnumerator<string>)))
                        return 1;
                // covariance on IEnumerator and covariance on arrays
-               if (!typeof (IEnumerator<object>[]).IsAssignableFrom (typeof 
(IEnumerator<string>[])))
+               if (!typeof (MyIEnumerator<object>[]).IsAssignableFrom (typeof 
(MyIEnumerator<string>[])))
                        return 2;
                // covariance and implemented interfaces
-               if (!typeof (IEnumerator<object>).IsAssignableFrom (typeof 
(Enumerator<string>)))
+               if (!typeof (MyIEnumerator<object>).IsAssignableFrom (typeof 
(Enumerator<string>)))
                        return 3;
 
                // contravariance on IComparer
@@ -254,6 +380,14 @@
                }
        }
 
+       static bool IsNull<T> (T t)
+       {
+               if (t == null)
+                       return true;
+               else
+                       return false;
+       }
+
        static object Box<T> (T t)
        {
                return t;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to