public static int test_0_tests () { // Check that creation of delegates do not runs the class cctor DoIt doit = new DoIt (B.method); if (A.b_cctor_run) return 1; Tests test = new Tests (); SimpleDelegate d = new SimpleDelegate (F); SimpleDelegate d1 = new SimpleDelegate (test.VF); NotSimpleDelegate d2 = new NotSimpleDelegate (G); NotSimpleDelegate d3 = new NotSimpleDelegate (test.H); d (); d1 (); // we run G() and H() before and after using them as delegates // to be sure we don't corrupt them. G (2); test.H (3); Console.WriteLine (d2 (2)); Console.WriteLine (d3 (3)); G (2); test.H (3); if (d.Method.Name != "F") return 1; if (d3.Method == null) return 1; object [] args = {3}; Console.WriteLine (d3.DynamicInvoke (args)); AnotherDelegate d4 = new AnotherDelegate (puts); if (d4.Method == null) return 1; Console.WriteLine (d4.Method); Console.WriteLine (d4.Method.Name); Console.WriteLine (d4.Method.DeclaringType); return 0; }
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; }
public static int test_0_tests() { DoIt doit = new DoIt (B.method); if (A.b_cctor_run) return 1; Tests test = new Tests (); SimpleDelegate d = new SimpleDelegate (F); SimpleDelegate d1 = new SimpleDelegate (test.VF); NotSimpleDelegate d2 = new NotSimpleDelegate (G); NotSimpleDelegate d3 = new NotSimpleDelegate (test.H); d (); d1 (); G (2); test.H (3); Console.WriteLine (d2 (2)); Console.WriteLine (d3 (3)); G (2); test.H (3); if (d.Method.Name != "F") return 1; if (d3.Method == null) return 1; object [] args = {3}; Console.WriteLine (d3.DynamicInvoke (args)); AnotherDelegate d4 = new AnotherDelegate (puts); if (d4.Method == null) return 1; Console.WriteLine (d4.Method); Console.WriteLine (d4.Method.Name); Console.WriteLine (d4.Method.DeclaringType); return 0; }