Merge pull request #4185 from BrzVlad/fix-arm64-finally-abort
[mono.git] / mcs / tests / gtest-linq-01.cs
index 88cc5da340ff9b9a518513f6b3e883023b7a7c5d..e6e8ec671f978ef28a953c0b8b83e12e87702f4d 100644 (file)
@@ -1,5 +1,3 @@
-// Compiler options: -langversion:linq
-
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,12 +11,12 @@ namespace from
 
        class C
        {
-               // This is pure grammar test
+               // This is pure grammar/parser test
                public static void Main ()
                {
                        int[] i2 = new int [] { 0, 1 };
                        int[] i_b = new int [] { 0, 1 };
-                       ITest[] join_test = null;
+                       ITest[] join_test = new ITest[0];
                        
                        IEnumerable<int> e;
                        IEnumerable<IGrouping<int,int>> g;
@@ -26,6 +24,7 @@ namespace from
                        // FROM
                        e = from i in i2 select i;
                        e = from int i in i2 select i;
+                       var e2 = from bool? i in i2 select i;
                        e = from i in new int[0] select i;
                        e = from x in i2 from y in i2 select y;
 
@@ -53,11 +52,77 @@ namespace from
                        // LET
                        e = from i in i2 let l = i + 4 select i;
                        e = from i in i2 let l = i + 4 let l2 = l + 2 select i;
+                       
+                       // INTO
+                       g = from i in i2 group i by 2 into i9
+                               from i in i2 group i by 2 into i9
+                               from i in i2 group i by 2 into i9
+                               from i in i2 group i by 2 into i9
+                               select i9;
+                               
+                       // NESTED
+                       var e3 = from a in
+                                       from b in i2
+                                       select b
+                               orderby a
+                               select a;
+                               
+                       var e4 = from i in
+                                       from x in i2
+                                       select x
+                               let l = from x2 in i2 select x2
+                               let l2 = 50
+                               select 1;
 
                        int from = 0;
                        bool let = false;
                        
+                       // TODO: Re-enable when we fix cast of query expression
                        //object o = (object)from i in i2 select i;
                }
+               
+               void Foo (int from, bool where)
+               {
+                       int Foo = 0;
+                       if (from < Foo) // This tests generics micro-parser awareness
+                               return;
+               }
+               
+               int foo;
+               void Do (string[] args)
+               {
+                       int from = this.foo;
+                       Console.WriteLine (args [from]);
+               }               
        }
-}
\ No newline at end of file
+       
+       class D
+       {
+               public bool check (object from, object to)
+               {
+                       if (from is int && to is int) return true;
+                               return false;
+               }
+       }
+}
+
+namespace FromProblems2
+{
+       class from
+       {
+       }
+       
+       class C
+       {
+               void M1 ()
+               {
+                       from local = new from ();
+               }
+               
+               from M2 ()
+               {
+                       return null;
+               }
+       }
+}
+