2007-10-26 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Fri, 26 Oct 2007 20:05:40 +0000 (20:05 -0000)
committerMarek Safar <marek.safar@gmail.com>
Fri, 26 Oct 2007 20:05:40 +0000 (20:05 -0000)
A tests for bug #335847

svn path=/trunk/mcs/; revision=88285

mcs/tests/gtest-initialize-05.cs [new file with mode: 0644]
mcs/tests/gtest-initialize-06.cs [new file with mode: 0644]
mcs/tests/test-392.cs [new file with mode: 0644]

diff --git a/mcs/tests/gtest-initialize-05.cs b/mcs/tests/gtest-initialize-05.cs
new file mode 100644 (file)
index 0000000..ecb6a14
--- /dev/null
@@ -0,0 +1,44 @@
+// Compiler options: -langversion:linq
+
+struct Point
+{
+       public int X, Y;
+}
+
+class C
+{
+       static Point p;
+       
+       public static int Main ()
+       {
+               new Point {
+                       X = 0,
+                       Y = 0
+               };
+               
+               var markerPosition = new Point {
+                       X = 2 * 3,
+                       Y = 9
+               };
+               
+               if (markerPosition.X != 6)
+                       return 1;
+               
+               if (markerPosition.Y != 9)
+                       return 2;
+               
+               Point[] pa = new Point[] { new Point { X = 9 }, new Point { X = 8 } };
+               
+               if (pa [0].X != 9)
+                       return 3;
+               
+               if (pa [1].X != 8)
+                       return 3;
+
+               p = new Point { Y = -1 };
+               if (p.Y != -1)
+                       return 4;
+               
+               return 0;
+       }
+}
diff --git a/mcs/tests/gtest-initialize-06.cs b/mcs/tests/gtest-initialize-06.cs
new file mode 100644 (file)
index 0000000..57df08a
--- /dev/null
@@ -0,0 +1,28 @@
+// Compiler options: -langversion:linq
+
+struct Point
+{
+       public int X, Y;
+}
+
+class C
+{
+       public static int Main ()
+       {
+               Point p;
+               Foo (out p);
+               
+               if (p.X != 3)
+                       return 1;
+               
+               if (p.Y != 5)
+                       return 2;
+               
+               return 0;
+       }
+       
+       static void Foo (out Point p)
+       {
+               p = new Point () { X = 3, Y = 5 };
+       }
+}
diff --git a/mcs/tests/test-392.cs b/mcs/tests/test-392.cs
new file mode 100644 (file)
index 0000000..93468b7
--- /dev/null
@@ -0,0 +1,31 @@
+public struct C
+{
+       struct S
+       {
+               public int i;
+               public S (int i)
+               {
+                       this.i = i;
+               }
+       }
+
+       static S[] s;
+       
+       int Test ()
+       {
+               int i = 0;
+               s = new S [1];
+               if (s.Length > 0)
+                       s [i++] = new S (10);
+               
+               if (s [0].i != 10)
+                       return 1;
+               
+               return 0;
+       }
+       
+       public static int Main ()
+       {
+               return new C().Test ();
+       }
+}
\ No newline at end of file