Merge pull request #4935 from lambdageek/dev-handles-may
[mono.git] / mcs / tests / gtest-039.cs
1 //
2 // Important test for the runtime: check whether we're correctly
3 // creating the vtable for nested types.
4 //
5
6 using System;
7
8 interface IMonkey<T>
9 {
10         T Jump ();
11 }
12
13 class Zoo<T>
14 {
15         T t;
16
17         public Zoo (T t)
18         {
19                 this.t = t;
20         }
21
22         public T Name {
23                 get { return t; }
24         }
25
26         public IMonkey<U> GetTheMonkey<U> (U u)
27         {
28                 return new Monkey<T,U> (this, u);
29         }
30
31         public class Monkey<V,W> : IMonkey<W>
32         {
33                 public readonly Zoo<V> Zoo;
34                 public readonly W Data;
35
36                 public Monkey (Zoo<V> zoo, W data)
37                 {
38                         this.Zoo = zoo;
39                         this.Data = data;
40                 }
41
42                 public W Jump ()
43                 {
44                         Console.WriteLine ("Monkey {0} from {1} jumping!", Data, Zoo.Name);
45                         return Data;
46                 }
47         }
48 }
49
50 class X
51 {
52         public static void Main ()
53         {
54                 Zoo<string> zoo = new Zoo<string> ("Boston");
55                 IMonkey<float> monkey = zoo.GetTheMonkey<float> (3.14F);
56                 monkey.Jump ();
57         }
58 }