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

test-anon-80.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 71a2e705e7dc4be3f6720446a595b50075539243 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;

namespace MonoBug
{
	sealed public class MyTest
	{
		sealed private class EventHandlers
		{
			private EventHandler _handler = DoNothingEventHandler;

			public static EventHandler DoNothingEventHandler
			{
				get
				{
					return delegate {
					};
				}
			}

			private int i;
			public EventHandler DoSomethingEventHandler
			{
				get
				{
					return delegate {
						++i;
					};
				}
			}

			public EventHandler Handler
			{
				get
				{
					return _handler;
				}
				set
				{
					_handler = value;
				}
			}
		}

		public static int Main ()
		{
			EventHandlers handlers = new EventHandlers ();
			handlers.Handler = handlers.DoSomethingEventHandler;

			Console.WriteLine ("Is handlers.Handler == handlers.DoSomethingEventHandler (instance)?");
			Console.WriteLine ("Expected: True");
			Console.Write ("Actual:   ");
			bool instanceEqual = handlers.Handler == handlers.DoSomethingEventHandler;
			Console.WriteLine (instanceEqual);
			Console.WriteLine ();

			handlers.Handler = EventHandlers.DoNothingEventHandler;
			Console.WriteLine ("Is handlers.Handler == EventHandlers.DoNothingEventHandler (static)?");
			Console.WriteLine ("Expected: True");
			Console.Write ("Actual:   ");
			bool staticEqual = handlers.Handler == EventHandlers.DoNothingEventHandler;
			Console.WriteLine (staticEqual);

			if (instanceEqual)
				if (staticEqual)
					return 0; // instance passed, static passed
				else
					return 1; // instance passed, static failed
			else
				if (staticEqual)
					return 2; // instance failed, static passed
				else
					return 3; // instance failed, static failed
		}
	}
}