Use g_assertion_message instead of exit to kill an iOS app.
[mono.git] / mono / mini / generics.cs
index ef5f3ac69d0bf8a6102581cb8de0223039b0809b..19282df514e273e5f2da45e6208e835255b34b58 100644 (file)
@@ -446,6 +446,29 @@ class Tests {
                return 0;
        }
 
+       public static int test_0_generic_virtual_on_interfaces_ref () {
+               Foo<string>.count1 = 0;
+               Foo<string>.count2 = 0;
+               Foo<string>.count3 = 0;
+               Foo<string>.count4 = 0;
+
+               IFoo f = new Foo<string> ("");
+               for (int i = 0; i < 1000; ++i) {
+                       f.Bar <string> ();
+                       f.Bar <object> ();
+                       f.NonGeneric ();
+               }
+
+               if (Foo<string>.count2 != 1000)
+                       return 2;
+               if (Foo<string>.count3 != 1000)
+                       return 3;
+               if (Foo<string>.count4 != 1000)
+                       return 4;
+
+               return 0;
+       }
+
        //repro for #505375
        [Category ("!FULLAOT")]
        public static int test_2_cprop_bug () {
@@ -773,7 +796,7 @@ class Tests {
                        GenericEvent (this);
                }
 
-               public static int count1, count2, count3;
+               public static int count1, count2, count3, count4;
 
                public void NonGeneric () {
                        count3 ++;
@@ -784,6 +807,8 @@ class Tests {
                                count1 ++;
                        else if (typeof (T) == typeof (string))
                                count2 ++;
+                       else if (typeof (T) == typeof (object))
+                               count4 ++;
                        return null;
                }
        }
@@ -849,4 +874,110 @@ class Tests {
                int result = foo.GetDefault<int>();
                return result;
        }
+
+       class Response {
+       }
+
+       public static int test_0_687865_isinst_with_cache_wrapper () {
+               object o = new object ();
+               if (o is Action<IEnumerable<Response>>)
+                       return 1;
+               else
+                       return 0;
+       }
+
+       enum DocType {
+               One,
+               Two,
+               Three
+       }
+
+       class Doc {
+               public string Name {
+                       get; set;
+               }
+
+               public DocType Type {
+                       get; set;
+               }
+       }
+
+       // #2155
+       public static int test_0_fullaot_sflda_cctor () {
+               List<Doc> documents = new List<Doc>();
+               documents.Add(new Doc { Name = "Doc1", Type = DocType.One } );
+               documents.Add(new Doc { Name = "Doc2", Type = DocType.Two } );
+               documents.Add(new Doc { Name = "Doc3", Type = DocType.Three } );
+               documents.Add(new Doc { Name = "Doc4", Type = DocType.One } );
+               documents.Add(new Doc { Name = "Doc5", Type = DocType.Two } );
+               documents.Add(new Doc { Name = "Doc6", Type = DocType.Three } );
+               documents.Add(new Doc { Name = "Doc7", Type = DocType.One } );
+               documents.Add(new Doc { Name = "Doc8", Type = DocType.Two } );
+               documents.Add(new Doc { Name = "Doc9", Type = DocType.Three } );
+
+               List<DocType> categories = documents.Select(d=>d.Type).Distinct().ToList<DocType>().OrderBy(d => d).ToList();
+               foreach(DocType cat in categories) {
+                       List<Doc> catDocs = documents.Where(d => d.Type == cat).OrderBy(d => d.Name).ToList<Doc>();
+               }
+               return 0;
+       }
+
+       class A { }
+
+    static List<A> sources = new List<A>();
+
+       // #6112
+    public static int test_0_fullaot_imt () {
+        sources.Add(null);
+        sources.Add(null);
+
+        int a = sources.Count;
+        var enumerator = sources.GetEnumerator() as IEnumerator<object>;
+
+        while (enumerator.MoveNext())
+        {
+            object o = enumerator.Current;
+        }
+
+               return 0;
+       }
+
+       struct Record : Foo2<Record>.IRecord {
+               int counter;
+               int Foo2<Record>.IRecord.DoSomething () {
+                       return counter++;
+               }
+       }
+
+       class Foo2<T> where T : Foo2<T>.IRecord {
+               public interface IRecord {
+                       int DoSomething ();
+               }
+
+               public static int Extract (T[] t) {
+                       return t[0].DoSomething ();
+               }
+       }
+
+       class Foo3<T> where T : IComparable {
+               public static int CompareTo (T[] t) {
+                       // This is a constrained call to Enum.CompareTo ()
+                       return t[0].CompareTo (t [0]);
+               }
+       }
+
+       public static int test_1_regress_constrained_iface_call_7571 () {
+        var r = new Record [10];
+        Foo2<Record>.Extract (r);
+               return Foo2<Record>.Extract (r);
+       }
+
+       enum ConstrainedEnum {
+               Val = 1
+       }
+
+       public static int test_0_regress_constrained_iface_call_enum () {
+               var r = new ConstrainedEnum [10];
+               return Foo3<ConstrainedEnum>.CompareTo (r);
+       }
 }