Add
authorMiguel de Icaza <miguel@gnome.org>
Tue, 8 Nov 2005 03:38:47 +0000 (03:38 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 8 Nov 2005 03:38:47 +0000 (03:38 -0000)
svn path=/trunk/mcs/; revision=52681

mcs/tests/test-469.cs [new file with mode: 0644]

diff --git a/mcs/tests/test-469.cs b/mcs/tests/test-469.cs
new file mode 100644 (file)
index 0000000..9e22aba
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Do not extend this test
+//
+// This test copes with the case where a parameter was already captured
+// and a second anonymous method on the same scope captured a parameter
+//
+using System;
+
+delegate void Del (int n);
+
+class Lambda {
+
+       static int v;
+
+       static void f (int va)
+       {
+               v = va;
+       }
+       
+       static Del[] Make2 (int x) { 
+               return new Del[] {
+                       delegate (int a) { f(x += a); },
+                       delegate (int b) { f(x += b); }
+               };
+       }
+  
+       static int Main () { 
+               Del[] d = Make2(10);
+               d[0](10);
+               if (v != 20)
+                       return 1;
+                                    
+               d[1](11);
+               if (v != 31)
+                       return 2;
+               Console.WriteLine ("OK");
+               return 0;
+       }
+}