codeowners update
[mono.git] / mcs / tests / test-anon-34.cs
1 //
2 // This test is from Nigel Perry, Bugzilla #77060
3 //
4 // The issue here was that in the past we used to emit the
5 // Scope initialization on first use, which is wrong as illustrated
6 // in this test (the shared scope is not initialized for differnt
7 // code paths).
8 //
9 // This test is a running test, ensuring that it runs
10 //
11 #region Using directives
12
13 using System;
14 using System.Collections;
15 using System.Text;
16 using System.Timers;
17
18 #endregion
19
20 namespace Delegates
21 { class Space
22   { public int Value;
23
24     public delegate void DoCopy();
25
26     public DoCopy CopyIt;
27
28     public void Leak(bool useArray, int max)
29     { DoCopy one = null;
30
31       if(useArray)
32       { 
33         int[] work;
34         
35         one = delegate 
36               { work = new int[max];
37               };
38       }
39       else
40       { 
41         one = delegate { int xans = (max + 1) * max / 2; };
42       }
43
44        Console.WriteLine("Here goes...");
45         one();
46         Console.WriteLine("... made it");
47     }
48   }
49
50   class Program
51   { static void SpaceLeak()
52     { Space s = new Space();
53
54       Console.WriteLine(s.Value);
55
56       s.Leak(false, 1);
57
58       Console.WriteLine(s.Value);
59     }
60
61     public static void Main(string[] args)
62     { SpaceLeak();
63     }
64   }
65 }