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>2010-08-02 20:37:43 +0400
committerMarek Safar <marek.safar@gmail.com>2010-08-02 20:41:41 +0400
commit7427251ee0f3f8dcaed866123d90585b1b106b8b (patch)
tree879dc5373da1fb8bb6bcb84daa40700b4adc7429 /mcs/tests/test-anon-96.cs
parent9ca5c25715a630d434578d8c721d97115c477384 (diff)
Initialize anonymous methods story for all sections inside switch block. Fixes #624324
Diffstat (limited to 'mcs/tests/test-anon-96.cs')
-rw-r--r--mcs/tests/test-anon-96.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/mcs/tests/test-anon-96.cs b/mcs/tests/test-anon-96.cs
new file mode 100644
index 00000000000..adad3ff9388
--- /dev/null
+++ b/mcs/tests/test-anon-96.cs
@@ -0,0 +1,54 @@
+using System;
+
+class P
+{
+ public int A;
+}
+
+static class Program
+{
+ static int Extra () { return 36; }
+
+ delegate int D ();
+
+ static D Get (int dummy)
+ {
+ var p = new P { A = 6 };
+ switch (dummy) {
+ case 0:
+ int extra = Extra ();
+ return () => p.A + extra;
+ case 1:
+ extra = 9;
+ return () => p.A * extra;
+ case 2:
+ return () => p.A * 2;
+ }
+ throw new NotSupportedException ();
+ }
+
+ static int Run (int i)
+ {
+ return Get (i) ();
+ }
+
+ static int Main ()
+ {
+ if (Run (0) != 42)
+ return 1;
+
+ if (Run (1) != 54)
+ return 2;
+
+ if (Run (2) != 12)
+ return 3;
+
+ if (Run (1) != 54)
+ return 4;
+
+ if (Run (0) != 42)
+ return 5;
+
+ return 0;
+ }
+}