Author: marek
Date: 2007-08-14 11:43:19 -0400 (Tue, 14 Aug 2007)
New Revision: 84088

Added:
   trunk/mcs/tests/gtest-collectioninit-02.cs
   trunk/mcs/tests/gtest-initialize-03.cs
Modified:
   trunk/mcs/tests/gtest-collectioninit-01.cs
Log:
More tests.



Modified: trunk/mcs/tests/gtest-collectioninit-01.cs
===================================================================
--- trunk/mcs/tests/gtest-collectioninit-01.cs  2007-08-14 15:42:24 UTC (rev 
84087)
+++ trunk/mcs/tests/gtest-collectioninit-01.cs  2007-08-14 15:43:19 UTC (rev 
84088)
@@ -1,23 +1,92 @@
 // Compiler options: -langversion:linq
 // Tests collection initialization
+
 using System;
 using System.Collections;
 using System.Collections.Generic;
 
 public class Test
 {
+       class Wrap
+       {
+               ArrayList numbers = new ArrayList ();
+               public int Id;
+               public Wrap Next;
+               
+               public Wrap ()
+               {
+                       Next = new Wrap (100);
+               }
+               
+               public Wrap (int i)
+               {
+                       Next = this;
+               }
+               
+               public ArrayList Numbers { 
+                       get { 
+                               return numbers;
+                       }
+               }
+       }
+       
+       static void TestList (List<int> list, int expectedCount)
+       {
+               if (list.Count != expectedCount)
+                       throw new ApplicationException (expectedCount.ToString 
());
+               
+               foreach (int i in list)
+                       Console.WriteLine (i);
+       }
+       
        static int Main ()
        {
-               ArrayList collection = new ArrayList { "Foo", "Bar", "Baz" };
-               foreach (string s in collection)
-                       if (s.Length != 3)
-                               return 1;
-               
+               ArrayList collection = new ArrayList { "Foo", null, 1 };
+               if (collection.Count != 3)
+                       return 1;
+                       
+               if ((string)collection [0] != "Foo")
+                       return 2;
+                       
+               if ((int)collection [2] != 1)
+                       return 3;
+                                       
                List<string> generic_collection = new List<string> { "Hello", 
"World" };
                foreach (string s in generic_collection)
                        if (s.Length != 5)
-                               return 2;
+                               return 4;
                
+               List<Wrap> a = null;
+               a = new List<Wrap> () {         
+                       new Wrap (0) {
+                               Id = 0,
+                               Numbers = { 5, 10 },
+                               Next = { Id = 55 }
+                       },
+                       new Wrap {
+                               Id = 1,
+                               Numbers = { collection, }
+                       },
+                       new Wrap {
+                               Id = 2,
+                               Numbers = { },
+                       },
+                       null
+               };
+               
+               if (a.Count != 4)
+                       return 5;
+               
+               if ((int)a [0].Numbers [1] != 10)
+                       return 6;
+               
+               new List<int> { 1, 2, 3, 4 };
+               TestList (new List<int> { 1, 2, 3, 4 }, 4);
+               
+               new List<int> { };
+               
+               Console.WriteLine ("OK");
                return 0;
        }
 }
+

Added: trunk/mcs/tests/gtest-collectioninit-02.cs
===================================================================
--- trunk/mcs/tests/gtest-collectioninit-02.cs  2007-08-14 15:42:24 UTC (rev 
84087)
+++ trunk/mcs/tests/gtest-collectioninit-02.cs  2007-08-14 15:43:19 UTC (rev 
84088)
@@ -0,0 +1,18 @@
+// Compiler options: -langversion:linq
+
+using System.Collections.Generic;
+
+public class C
+{
+       public static int Main ()
+       {
+               var o = new Dictionary<string, int>() { { "Foo", 3 } };
+               if (o ["Foo"] != 3)
+                       return 1;
+               
+               o = new Dictionary<string, int>() { { "A", 1 }, { "B", 2 } };
+
+               return 0;
+       }
+}
+


Property changes on: trunk/mcs/tests/gtest-collectioninit-02.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/mcs/tests/gtest-initialize-03.cs
===================================================================
--- trunk/mcs/tests/gtest-initialize-03.cs      2007-08-14 15:42:24 UTC (rev 
84087)
+++ trunk/mcs/tests/gtest-initialize-03.cs      2007-08-14 15:43:19 UTC (rev 
84088)
@@ -0,0 +1,30 @@
+// Compiler options: -langversion:linq
+
+using System;
+using System.Collections;
+
+class Data
+{
+       public int Value;
+}
+
+public class Test
+{
+       static Data Prop {
+               set {
+               }
+       }
+       
+       public object Foo ()
+       {
+               return new Data () { Value = 3 };
+       }
+       
+       static void Main ()
+       {
+               Prop = new Data () { Value = 3 };
+               Data data = new Data () { Value = 6 };
+               Data a, b;
+               a = b = new Data () { Value = 3 };
+       }
+}

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

Reply via email to