Merge pull request #487 from mayerwin/patch-1
[mono.git] / mcs / tests / test-anon-33.cs
1 //
2 // This test showed that there were cases where there was no
3 // shared "ScopeInfo", and that we could not root and keep a "topmost"
4 // variable in the compiler for a CaptureContext.
5 //
6 // This illustrates two roots of captured scopes, independent of
7 // each other
8 //
9
10 using System;
11
12 delegate void Do ();
13
14 class T {
15         static void doit (int v) {
16                 Console.WriteLine (v);
17         }
18         public static void Main () {
19                 Do[] arr = new Do [5];
20                 for (int i = 0; i < 5; ++i) {
21                         arr [i] = delegate {doit (i);};
22                 }
23                 for (int i = 0; i < 5; ++i) {
24                         arr [i] ();
25                 }
26 {
27                 for (int j = 0; j < 5; ++j) {
28                         arr [j] = delegate {doit (j);};
29                 }
30 }
31         }
32
33 }
34
35