New tests.
[mono.git] / mono / mini / generics.cs
index d880ca92dd3824622e4c8b6851e7ca033300b9d9..a75e3ad59a8f5c5a21a2c5a0b29374f3787d9914 100644 (file)
@@ -556,6 +556,74 @@ class Tests {
                return t () == typeof (T) ? 0 : 1;
        }
 
+       public static int test_0_marshalbyref_call_from_gshared_virt_elim () {
+               /* Calling a virtual method from gshared code which is changed to a nonvirt call */
+               Class1<object> o = new Class1<object> ();
+               o.Do (new Class2<object> ());
+               return 0;
+       }
+
+       public static int test_0_partial_sharing () {
+               if (PartialShared1 (new List<string> (), 1) != typeof (string))
+                       return 1;
+               if (PartialShared1 (new List<Tests> (), 1) != typeof (Tests))
+                       return 2;
+               if (PartialShared2 (new List<string> (), 1) != typeof (int))
+                       return 3;
+               if (PartialShared2 (new List<Tests> (), 1) != typeof (int))
+                       return 4;
+               return 0;
+       }
+
+       public static int test_6_partial_sharing_linq () {
+               var messages = new List<Message> ();
+
+               messages.Add (new Message () { MessageID = 5 });
+               messages.Add (new Message () { MessageID = 6 });
+
+               return messages.Max(i => i.MessageID);
+       }
+
+       public static int test_0_partial_shared_method_in_nonshared_class () {
+               var c = new Class1<double> ();
+               return (c.Foo<string> (5).GetType () == typeof (Class1<string>)) ? 0 : 1;
+       }
+
+       class Message {
+               public int MessageID {
+                       get; set;
+               }
+       }
+
+       public static Type PartialShared1<T, K> (List<T> list, K k) {
+               return typeof (T);
+       }
+
+       public static Type PartialShared2<T, K> (List<T> list, K k) {
+               return typeof (K);
+       }
+
+    public class Class1<T> {
+               public virtual void Do (Class2<T> t) {
+                       t.Foo ();
+               }
+
+               public virtual object Foo<U> (T t) {
+                       return new Class1<U> ();
+               }
+       }
+
+       public interface IFace1<T> {
+               void Foo ();
+       }
+
+       public class Class2<T> : MarshalByRefObject, IFace1<T> {
+               public void Foo () {
+               }
+       }
+
+
+
        public static void VirtualInterfaceCallFromGenericMethod <T> (IFoo f) {
                f.Bar <T> ();
        }