linux-packaging-mono/mcs/tests/test-anon-34.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

66 lines
1.2 KiB
C#

//
// This test is from Nigel Perry, Bugzilla #77060
//
// The issue here was that in the past we used to emit the
// Scope initialization on first use, which is wrong as illustrated
// in this test (the shared scope is not initialized for differnt
// code paths).
//
// This test is a running test, ensuring that it runs
//
#region Using directives
using System;
using System.Collections;
using System.Text;
using System.Timers;
#endregion
namespace Delegates
{ class Space
{ public int Value;
public delegate void DoCopy();
public DoCopy CopyIt;
public void Leak(bool useArray, int max)
{ DoCopy one = null;
if(useArray)
{
int[] work;
one = delegate
{ work = new int[max];
};
}
else
{
one = delegate { int xans = (max + 1) * max / 2; };
}
Console.WriteLine("Here goes...");
one();
Console.WriteLine("... made it");
}
}
class Program
{ static void SpaceLeak()
{ Space s = new Space();
Console.WriteLine(s.Value);
s.Leak(false, 1);
Console.WriteLine(s.Value);
}
public static void Main(string[] args)
{ SpaceLeak();
}
}
}