Merge pull request #4419 from BrzVlad/fix-oom-nre
[mono.git] / mcs / tests / test-anon-94.cs
1 // Compiler options: -r:test-anon-94-lib.dll
2
3 using System;
4
5 class Program
6 {
7         public class BaseClass
8         {
9                 public int i;
10                 public virtual void Print () { Console.WriteLine ("BaseClass.Print"); i = 90; }
11                 public virtual void TestOut (out int arg) { arg = 4; }
12         }
13
14         public class Derived : BaseClass
15         {
16                 public override void Print ()
17                 {
18                         Action a = () => base.Print ();
19                         a ();
20                 }
21                 
22                 public override void TestOut (out int arg)
23                 {
24                         int p = 9;
25                         Action a = () => {
26                                 base.TestOut (out p);
27                                 Console.WriteLine (p);
28                         };
29                         
30                         a ();
31                         arg = p;
32                 }
33         }
34         
35         public class DerivedLibrary : BaseClassLibrary
36         {
37                 public override void Print (int arg)
38                 {
39                         Action a = () => base.Print (30);
40                         a ();
41                 }
42         }
43
44         public static int Main ()
45         {
46                 var d = new Derived ();
47                 d.Print ();
48
49                 if (d.i != 90)
50                         return 1;
51                 
52                 int arg;
53                 d.TestOut (out arg);
54                 if (arg != 4)
55                         return 2;
56
57                 var d2 = new DerivedLibrary ();
58                 d2.Print (0);
59
60                 if (d2.i != 30)
61                         return 3;
62
63                 return 0;
64         }
65 }