Fix bug #566087.
[mcs.git] / tests / test-anon-80.cs
blob8e06bb2e6d005db78f75895f81ad4e75d931f396
1 using System;
3 namespace MonoBug
5 sealed public class MyTest
7 sealed private class EventHandlers
9 private EventHandler _handler = DoNothingEventHandler;
11 public static EventHandler DoNothingEventHandler
13 get
15 return delegate {
20 private int i;
21 public EventHandler DoSomethingEventHandler
23 get
25 return delegate {
26 ++i;
31 public EventHandler Handler
33 get
35 return _handler;
37 set
39 _handler = value;
44 static int Main ()
46 EventHandlers handlers = new EventHandlers ();
47 handlers.Handler = handlers.DoSomethingEventHandler;
49 Console.WriteLine ("Is handlers.Handler == handlers.DoSomethingEventHandler (instance)?");
50 Console.WriteLine ("Expected: True");
51 Console.Write ("Actual: ");
52 bool instanceEqual = handlers.Handler == handlers.DoSomethingEventHandler;
53 Console.WriteLine (instanceEqual);
54 Console.WriteLine ();
56 handlers.Handler = EventHandlers.DoNothingEventHandler;
57 Console.WriteLine ("Is handlers.Handler == EventHandlers.DoNothingEventHandler (static)?");
58 Console.WriteLine ("Expected: True");
59 Console.Write ("Actual: ");
60 bool staticEqual = handlers.Handler == EventHandlers.DoNothingEventHandler;
61 Console.WriteLine (staticEqual);
63 if (instanceEqual)
64 if (staticEqual)
65 return 0; // instance passed, static passed
66 else
67 return 1; // instance passed, static failed
68 else
69 if (staticEqual)
70 return 2; // instance failed, static passed
71 else
72 return 3; // instance failed, static failed