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

test-228.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 32124f7c8e510eaae753a55d838de97bf0bd73eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Test for bug reported on the list.  The bug was that the 
// compiler was generating copies of the static variable, before
// passing it.  A trick that we do for readonly variables
using System;

namespace BadRefTest
{

public class CtorInc
{
	static int x, y;

	static int IncByRef(ref int i) { return ++i; }

	public CtorInc() { IncByRef(ref x); ++y; }

	public static bool Results(int total)
	{
		Console.WriteLine("CtorInc test {0}: x == {1}, y == {2}",
				x == y && x == total? "passed": "failed", x, y);

		return x == y && x == total;
	}
}

public class Runner
{
	public static int Main()
	{
		int i = 0;
		for (; i < 5; i++)
		{
			CtorInc t = new CtorInc();
		}
		return CtorInc.Results(i) ? 0 : 1;
	}

}
}