New tests.
authorMarek Safar <marek.safar@gmail.com>
Thu, 29 Apr 2010 10:45:23 +0000 (10:45 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 29 Apr 2010 10:45:23 +0000 (10:45 -0000)
svn path=/trunk/mcs/; revision=156410

mcs/tests/gtest-499.cs [new file with mode: 0644]
mcs/tests/gtest-anon-24.cs
mcs/tests/ver-il-gmcs.xml

diff --git a/mcs/tests/gtest-499.cs b/mcs/tests/gtest-499.cs
new file mode 100644 (file)
index 0000000..3435c4b
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+using System.Reflection;
+
+public class C
+{
+       public static int Test<T> (T[] t)
+       {
+               // Has to include readonly. prefix
+               return t[0].GetHashCode ();
+       }
+
+       public static int TestExtra<T> (T[,] t)
+       {
+               // Has to include readonly. prefix
+               return t[0, 0].GetHashCode ();
+       }
+
+       public static int Main ()
+       {
+               Test (new[] { 2.1, 4.5 });
+               Test (new[] { "b" });
+
+               var body = typeof (C).GetMethod ("Test").GetMethodBody ();
+
+               // Check for readonly. (0xFE1E)
+               var array = body.GetILAsByteArray ();
+               if (array[2] != 0xFE)
+                       return 1;
+
+               if (array[3] != 0x1E)
+                       return 1;
+
+               return 0;
+       }
+}
index 103ba8d0537fc87baa348a1b8927e296b203322f..60dc0ce3d0e40c2948fbc5d2060fb64d394093b2 100644 (file)
@@ -10,7 +10,7 @@ class Disposable<T> : IDisposable
        }
 }
 
-interface IFoo<TOne,TTwo>
+interface IFoo<TOne, TTwo>
 {
 }
 
@@ -27,16 +27,16 @@ class Test
 {
        static Func<T[]> For<T> (List<T> list)
        {
-               T [] t = new T [2];
+               T[] t = new T[2];
                return () => {
                        for (int i = 0; i < t.Length; ++i) {
-                               t [i] = list [i];
+                               t[i] = list[i];
                        }
-                       
+
                        return t;
                };
        }
-       
+
        static Func<T> Throw<T> (T t)
        {
                T l = t;
@@ -44,19 +44,19 @@ class Test
                        throw new ApplicationException (l.ToString ());
                };
        }
-       
+
        static Func<Type> TypeOf<T> (T t)
        {
                T l = t;
                return () => {
                        l = t;
-                       var e = typeof (Disposable <T>);
-                       e = typeof (Disposable <>);
-                       e = typeof (IFoo <,>);
+                       var e = typeof (Disposable<T>);
+                       e = typeof (Disposable<>);
+                       e = typeof (IFoo<,>);
                        return typeof (T);
                };
        }
-       
+
        static Func<T> Do<T> (T t)
        {
                T l = t;
@@ -65,23 +65,22 @@ class Test
                        do {
                                t2 = l;
                        } while (default (T) != null);
-                       
+
                        return t2;
                };
        }
-       
+
        static Func<T> Lock<T> (T t)
        {
                T l = t;
                return () => {
-                       lock (l.GetType ())
-                       {
+                       lock (l.GetType ()) {
                                l = default (T);
                                return l;
                        }
                };
        }
-       
+
        static Func<T> Catch<T> (T t)
        {
                T l = t;
@@ -93,96 +92,101 @@ class Test
                        }
                };
        }
-       
+
        static Func<T> Finally<T> (T t)
        {
                T l = t;
                return () => {
                        try {
-                               l = Lock (l)();
+                               l = Lock (l) ();
                        } finally {
                                l = default (T);
                        }
-                       
+
                        return l;
                };
        }
-       
+
        static Func<T> Using<T> (T t)
        {
                T l = t;
-               using (var d = new Disposable<T> ())
-               {
+               using (var d = new Disposable<T> ()) {
                        return () => {
                                return l;
                        };
                }
        }
-       
+
        static Func<T> Switch<T> (T t)
        {
                T l = t;
                int? i = 0;
                return () => {
                        switch (i) {
-                               default: return l;
+                       default: return l;
                        }
                };
        }
-       
+
        static Func<List<T>> ForForeach<T> (T[] t)
        {
                return () => {
                        foreach (T e in t)
                                return new List<T> () { e };
-                       
+
                        throw new ApplicationException ();
                };
        }
-       
+
        public void ArrayMutate<T> (T[] array)
        {
                int r = 4;
                Action<int> anonMeth = delegate (int slc) {
                        long[] idx = new long[] { 0, 0 };
                        for (int i = 0; i < r; i++) {
-                               idx [0] = i;
+                               idx[0] = i;
                        }
                };
        }
-       
+
        static Func<T[][]> ArrayMultiMutate<T> (T[][] array)
        {
                return () => {
                        for (int i = 0; i < 3; i++) {
-                               array [i][i] = default (T);
+                               array[i][i] = default (T);
                        }
-                       
+
                        return array;
                };
        }
-       
+
+       static Func<int> ArrayMultiMutate<T> (T[,] array)
+       {
+               return () => {
+                       return array[0, 0].GetHashCode ();
+               };
+       }
+
        static Func<T[]> NestedTypeMutate<T> ()
        {
                var local = new CA<T>.Nested ();
                return () => {
-                       return new [] { CA<T>.Nested.Value, local.Value2 };
+                       return new[] { CA<T>.Nested.Value, local.Value2 };
                };
        }
-       
+
        public static int Main ()
        {
-               if (For (new List<int> { 5, 10 })() [1] != 10)
+               if (For (new List<int> { 5, 10 }) ()[1] != 10)
                        return 1;
-               
+
                var t = Throw (5);
                try {
                        t ();
                        return 2;
-               } catch (ApplicationException)
-               {
+               } catch (ApplicationException) {
                }
-               
+
                var t3 = Do ("rr");
                if (t3 () != "rr")
                        return 3;
@@ -190,7 +194,7 @@ class Test
                var t4 = Lock ('f');
                if (t4 () != '\0')
                        return 4;
-               
+
                var t5 = Catch (3);
                if (t5 () != 3)
                        return 5;
@@ -198,29 +202,34 @@ class Test
                var t6 = Finally (5);
                if (t6 () != 0)
                        return 6;
-               
+
                var t7 = Using (1.1);
                if (t7 () != 1.1)
                        return 7;
-               
+
                var t8 = Switch (55);
                if (t8 () != 55)
                        return 8;
-               
-               var t9 = ForForeach (new [] { 4, 1 });
+
+               var t9 = ForForeach (new[] { 4, 1 });
                if (t9 ()[0] != 4)
                        return 9;
-                       
-               var t10 = ArrayMultiMutate (new string [][] { new string [] { "a", "b", "c" }, new string [] { "1", "2", "3" }, new string [] { "A", "B", "C" }});
-               if (t10 () [2] [2] != null)
+
+               var t10 = ArrayMultiMutate (new string[][] { new string[] { "a", "b", "c" }, new string[] { "1", "2", "3" }, new string[] { "A", "B", "C" } });
+               if (t10 ()[2][2] != null)
                        return 10;
-               
+
+               var array = new short[,] { { 10, 20 } };
+               var t10a = ArrayMultiMutate (array);
+               if (t10a () != array[0, 0].GetHashCode ())
+                       return 100;
+
                var t11 = TypeOf ("b");
                if (t11 () != typeof (string))
                        return 11;
-               
-               var t12 = NestedTypeMutate<ulong> ()();
-               if (t12 [0] != 0 || t12 [1] != 0)
+
+               var t12 = NestedTypeMutate<ulong> () ();
+               if (t12[0] != 0 || t12[1] != 0)
                        return 12;
 
                Console.WriteLine ("OK");
index 2556773c9ff5eed3acf93ac869a1dd167c404b03..feb8fc313b92e030ae0b805b5d7b536fa9c31e80 100644 (file)
         <size>14</size>
       </method>
       <method name="Polynomial`1[E] Add(Polynomial`1[E])">
-        <size>297</size>
+        <size>301</size>
       </method>
       <method name="Polynomial`1[E] Add(E)">
         <size>26</size>
         <size>78</size>
       </method>
       <method name="Polynomial`1[E] Mul(Polynomial`1[E])">
-        <size>219</size>
+        <size>221</size>
       </method>
       <method name="E Eval(E)">
         <size>106</size>
       </method>
     </type>
   </test>
+  <test name="gtest-499.cs">
+    <type name="C">
+      <method name="Int32 Test[T](T[])">
+        <size>21</size>
+      </method>
+      <method name="Int32 TestExtra[T](T[,])">
+        <size>22</size>
+      </method>
+      <method name="Int32 Main()">
+        <size>118</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="gtest-anon-1.cs">
     <type name="X">
       <method name="Void .ctor()">
         <size>26</size>
       </method>
       <method name="Int32 Main()">
-        <size>501</size>
+        <size>568</size>
       </method>
     </type>
     <type name="Test+&lt;For&gt;c__AnonStorey0`1[T]">
       <method name="System.Func`1[T[]] NestedTypeMutate[T]()">
         <size>34</size>
       </method>
+      <method name="System.Func`1[System.Int32] ArrayMultiMutate[T](T[,])">
+        <size>26</size>
+      </method>
+    </type>
+    <type name="Test+&lt;ArrayMultiMutate&gt;c__AnonStoreyC`1[T]">
+      <method name="Int32 &lt;&gt;m__C()">
+        <size>27</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
     </type>
-    <type name="Test+&lt;NestedTypeMutate&gt;c__AnonStoreyC`1[T]">
-      <method name="T[] &lt;&gt;m__C()">
+    <type name="Test+&lt;NestedTypeMutate&gt;c__AnonStoreyD`1[T]">
+      <method name="T[] &lt;&gt;m__D()">
         <size>37</size>
       </method>
       <method name="Void .ctor()">
         <size>7</size>
       </method>
       <method name="Boolean Equals(System.Object)">
-        <size>89</size>
+        <size>91</size>
       </method>
     </type>
     <type name="Indexer">