Author: martin
Date: 2006-11-17 14:18:25 -0500 (Fri, 17 Nov 2006)
New Revision: 68085

Added:
   branches/martin/anonymous-methods2/work/test-martin-4.cs
   branches/martin/anonymous-methods2/work/test-martin-5.cs
   branches/martin/anonymous-methods2/work/test-martin-6.cs
Modified:
   branches/martin/anonymous-methods2/work/known-issues
Log:
New tests.

Modified: branches/martin/anonymous-methods2/work/known-issues
===================================================================
--- branches/martin/anonymous-methods2/work/known-issues        2006-11-17 
19:01:11 UTC (rev 68084)
+++ branches/martin/anonymous-methods2/work/known-issues        2006-11-17 
19:18:25 UTC (rev 68085)
@@ -1,3 +1,6 @@
 test-martin-1.cs
 test-martin-2.cs
 test-martin-3.cs
+test-martin-4.cs
+test-martin-5.cs
+test-martin-6.cs

Added: branches/martin/anonymous-methods2/work/test-martin-4.cs
===================================================================
--- branches/martin/anonymous-methods2/work/test-martin-4.cs    2006-11-17 
19:01:11 UTC (rev 68084)
+++ branches/martin/anonymous-methods2/work/test-martin-4.cs    2006-11-17 
19:18:25 UTC (rev 68085)
@@ -0,0 +1,77 @@
+using System;
+
+public class X
+{
+       public delegate void TestDelegate ();
+
+       static long sum_i, sum_j, sum_k;
+       static ulong sum_p, sum_q;
+
+       public static int Test (int p)
+       {
+               TestDelegate d = null;
+               for (int i = 1; i <= 5; i++) {
+                       for (int j = i; j <= 8; j++) {
+                               int k = i;
+                               TestDelegate temp = delegate {
+                                       Console.WriteLine ("i = {0}, j = {1}, k 
= {2}, p = {3}",
+                                                          i, j, k, p);
+                                       sum_i += 1 << i;
+                                       sum_j += 1 << j;
+                                       sum_k += 1 << k;
+                                       sum_p += (ulong) (1 << p);
+                                       p += k;
+
+                                       ulong q = (ulong) (i * j);
+
+                                       d += delegate {
+                                               Console.WriteLine ("Nested i = 
{0}, j = {1}, " +
+                                                                  "k = {2}, p 
= {3}, q = {4}",
+                                                                  i, j, k, p, 
q);
+                                               sum_q += q;
+                                       };
+                               };
+                               temp ();
+                               d += temp;
+                       }
+               }
+               Console.WriteLine ("SUM i = {0}, j = {1}, k = {2}, p = {3}",
+                                  sum_i, sum_j, sum_k, sum_p);
+               Console.WriteLine ();
+               if (sum_i != 300)
+                       return 1;
+               if (sum_j != 2498)
+                       return 2;
+               if (sum_k != 300)
+                       return 3;
+               if (sum_p != 1825434804)
+                       return 4;
+               sum_i = sum_j = sum_k = 0;
+               sum_p = sum_q = 0;
+               d();
+               Console.WriteLine ("SUM i = {0}, j = {1}, k = {2}, p = {3}, q = 
{4}",
+                                  sum_i, sum_j, sum_k, sum_p, sum_q);
+               Console.WriteLine ();
+               if (sum_i != 1920)
+                       return 5;
+               if (sum_j != 15360)
+                       return 6;
+               if (sum_k != 300)
+                       return 7;
+               if (sum_p != 18446744073385831629)
+                       return 8;
+               if (sum_q != 455)
+                       return 9;
+               return 0;
+       }
+
+       public static int Main ()
+       {
+               int result = Test (5);
+               if (result != 0)
+                       Console.WriteLine ("ERROR: {0}", result);
+               else
+                       Console.WriteLine ("OK");
+               return result;
+       }
+}


Property changes on: branches/martin/anonymous-methods2/work/test-martin-4.cs
___________________________________________________________________
Name: svn:executable
   + *

Added: branches/martin/anonymous-methods2/work/test-martin-5.cs
===================================================================
--- branches/martin/anonymous-methods2/work/test-martin-5.cs    2006-11-17 
19:01:11 UTC (rev 68084)
+++ branches/martin/anonymous-methods2/work/test-martin-5.cs    2006-11-17 
19:18:25 UTC (rev 68085)
@@ -0,0 +1,28 @@
+using System;
+
+public delegate void Foo<R> (R r);
+
+class Test<T>
+{
+       public static void Hello<S> (T t, S s)
+       {
+               Foo<long> foo = delegate (long r) {
+                       Console.WriteLine (r);
+                       Foo<T> bar = delegate (T x) {
+                               Console.WriteLine (r);
+                               Console.WriteLine (t);
+                               Console.WriteLine (s);
+                               Console.WriteLine (x);
+                       };
+                       bar (t);
+               };
+               foo (5);
+       }
+}
+
+class X
+{
+       static void Main ()
+       {
+       }
+}


Property changes on: branches/martin/anonymous-methods2/work/test-martin-5.cs
___________________________________________________________________
Name: svn:executable
   + *

Added: branches/martin/anonymous-methods2/work/test-martin-6.cs
===================================================================
--- branches/martin/anonymous-methods2/work/test-martin-6.cs    2006-11-17 
19:01:11 UTC (rev 68084)
+++ branches/martin/anonymous-methods2/work/test-martin-6.cs    2006-11-17 
19:18:25 UTC (rev 68085)
@@ -0,0 +1,57 @@
+using System;
+
+public class X
+{
+       public int p;
+       public delegate void TestDelegate ();
+
+       static long sum_i, sum_k, sum_p;
+
+       public int Test ()
+       {
+               TestDelegate d = null;
+               for (int i = 1; i <= 5; i++) {
+                       int k = i;
+                       TestDelegate temp = delegate {
+                               Console.WriteLine ("i = {0}, k = {1}, p = {2}", 
i, k, p);
+                               sum_i += 1 << i;
+                               sum_k += 1 << k;
+                               sum_p += 1 << p;
+                               p += k;
+                       };
+                       temp ();
+                       d += temp;
+               }
+               Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, 
sum_k, sum_p);
+               Console.WriteLine ();
+               if (sum_i != 62)
+                       return 1;
+               if (sum_k != 62)
+                       return 2;
+               if (sum_p != 35168)
+                       return 3;
+               sum_i = sum_k = sum_p = 0;
+               d();
+               Console.WriteLine ("SUM i = {0}, k = {1}, p = {2}", sum_i, 
sum_k, sum_p);
+               Console.WriteLine ();
+               if (sum_i != 320)
+                       return 4;
+               if (sum_k != 62)
+                       return 5;
+               if (sum_p != 1152385024)
+                       return 6;
+               return 0;
+       }
+
+       public static int Main ()
+       {
+               X x = new X ();
+               x.p = 5;
+               int result = x.Test ();
+               if (result != 0)
+                       Console.WriteLine ("ERROR: {0}", result);
+               else
+                       Console.WriteLine ("OK");
+               return result;
+       }
+}

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

Reply via email to