Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2008-07-16 19:32:44 +0400
committerMarek Safar <marek.safar@gmail.com>2008-07-16 19:32:44 +0400
commitd0b508303ec958a0eb114fcfd655aff3e71ea66d (patch)
tree68f1a91f8a68d4f4d6e091315ef061328cebd5bf /mcs/tests/test-anon-82.cs
parent7f29c4c77e4ae1c9b2a0ce355d03485e17af1a08 (diff)
New test.
svn path=/trunk/mcs/; revision=108047
Diffstat (limited to 'mcs/tests/test-anon-82.cs')
-rwxr-xr-xmcs/tests/test-anon-82.cs79
1 files changed, 79 insertions, 0 deletions
diff --git a/mcs/tests/test-anon-82.cs b/mcs/tests/test-anon-82.cs
new file mode 100755
index 00000000000..5c889bec90d
--- /dev/null
+++ b/mcs/tests/test-anon-82.cs
@@ -0,0 +1,79 @@
+//
+// Tests different anonymous method caching scenarios
+//
+
+public delegate void StringSender (string str);
+public delegate void VoidDelegate ();
+
+public class MainClass
+{
+ public static void Main()
+ {
+ MainClass mc = new MainClass ();
+ VoidDelegate del = new VoidDelegate (
+ delegate {
+ StringSender ss = delegate (string s) {
+ SimpleCallback(mc, s);
+ };
+ ss("Yo!");
+ }
+ );
+ del();
+
+ mc.Test2 (10);
+ mc.Test3 (20);
+ mc.Test4 ();
+ mc.Test5 (50);
+ }
+
+ void Test2 (int a)
+ {
+ StringSender d = delegate (string s) {
+ VoidDelegate d2 = delegate {
+ s = "10";
+ };
+ };
+ }
+
+ void Test3 (int a)
+ {
+ int u = 8;
+ VoidDelegate d = delegate () { u = 9; };
+ VoidDelegate d2 = delegate () { };
+ }
+
+ void Test4 ()
+ {
+ VoidDelegate d = delegate () {
+ VoidDelegate d2 = delegate () {
+ int a = 9;
+ VoidDelegate d3 = delegate () {
+ VoidDelegate d4 = delegate () {
+ a = 3;
+ };
+ };
+ };
+ };
+ }
+
+ int a;
+ int b;
+
+ delegate int D (int a);
+
+ void Test5 (int arg)
+ {
+ D d2 = delegate (int i) {
+ D d1 = delegate (int a) {
+ return a;
+ };
+
+ return d1 (9) + arg;
+ };
+ }
+
+ static void SimpleCallback (MainClass mc, string str)
+ {
+ System.Console.WriteLine(str);
+ }
+}