In class/Microsoft.Build.Tasks:
[mcs.git] / tests / test-149.cs
blob32a9c19846e9cac7b39c1747e017a67e14644ce4
1 using System;
3 public delegate long MyDelegate (int a);
5 public interface X
7 event EventHandler Foo;
9 event MyDelegate TestEvent;
12 public class Y : X
14 static int a = 0;
16 event EventHandler X.Foo {
17 add {
20 remove {
24 public event EventHandler Foo;
26 public event MyDelegate TestEvent;
28 public int Test ()
30 X x = this;
32 Foo += new EventHandler (callback1);
33 TestEvent += new MyDelegate (callback2);
35 x.Foo += new EventHandler (callback3);
37 if (a != 0)
38 return 1;
40 Foo (this, new EventArgs ());
41 if (a != 1)
42 return 2;
44 if (TestEvent (2) != 4)
45 return 3;
47 if (a != 2)
48 return 4;
50 return 0;
54 private static void callback1 (object sender, EventArgs e)
56 a = 1;
59 private static long callback2 (int b)
61 a = b;
62 return a * a;
65 private static void callback3 (object sender, EventArgs e)
67 a = 3;
71 public class Z : Y
73 public delegate int SomeEventHandler();
74 public static event SomeEventHandler BuildStarted;
76 static int a ()
78 return 1;
80 public static int Main ()
82 Z z = new Z ();
84 int result = z.Test ();
86 if (result != 0)
87 return result;
89 if (BuildStarted != null) {
90 BuildStarted();
92 BuildStarted = new SomeEventHandler (a);
93 if (BuildStarted () != 1)
94 return 50;
96 return 0;
101 // This class is just to test a bug in mcs; where we used to fail
102 // when accessing a static event, from an instance method.
104 public class Static {
105 public static event EventHandler Test;
107 public void Fire()
109 if ( Test != null )
110 Test (null, null);