X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Ftests%2Fdelegate.cs;h=fda09b6ccf12a0bd5e88a17fb60345e0c895bec2;hb=438e3b5ac335f69a620d2db738626fca1d0c2980;hp=269c10aa7a0743ab9093028e46a712f8bea97ef6;hpb=07ec1253c277856bdbb74213e2defc8ed23cf8e3;p=mono.git diff --git a/mono/tests/delegate.cs b/mono/tests/delegate.cs index 269c10aa7a0..fda09b6ccf1 100644 --- a/mono/tests/delegate.cs +++ b/mono/tests/delegate.cs @@ -138,5 +138,76 @@ class Tests { return (int)l (55); } + static int count = 0; + + public static void inc_count () { + count ++; + } + + public static int test_0_multicast () { + SimpleDelegate d = new SimpleDelegate (inc_count); + + d += inc_count; + + d (); + return count == 2 ? 0 : 1; + } + + public delegate int Delegate0 (); + + public delegate int Delegate1 (int i); + + public delegate int Delegate2 (int i, int j); + + public int int_field; + + public int adder0 () { + return int_field; + } + + public static int adder0_static () { + return 1; + } + + public int adder1 (int i) { + return int_field + i; + } + + public static int adder1_static (int i) { + return i; + } + + public int adder2 (int i, int j) { + return int_field + i + j; + } + + public static int adder2_static (int i, int j) { + return i + j; + } + + public static int test_0_delegate_opt () { + Tests d = new Tests (); + d.int_field = 1; + + if (new Delegate0 (d.adder0) () != 1) + return 1; + + if (new Delegate1 (d.adder1) (2) != 3) + return 2; + + if (new Delegate2 (d.adder2) (2, 3) != 6) + return 3; + + if (new Delegate0 (adder0_static) () != 1) + return 4; + + if (new Delegate1 (adder1_static) (2) != 2) + return 5; + + if (new Delegate2 (adder2_static) (2, 3) != 5) + return 6; + + return 0; + } } }