Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / tests / gtest-038.cs
1 //
2 // Another important test: nested generic types.
3 //
4
5 using System;
6
7 class Queue<T>
8 {
9         public Queue (T first, T second)
10         {
11                 head = new Node<T> (null, second);
12                 head = new Node<T> (head, first);
13         }
14
15         protected Node<T> head;
16
17         protected Node<T> GetFoo ()
18         {
19                 return head;
20         }
21
22         protected Node<T> Foo {
23                 get {
24                         return GetFoo ();
25                 }
26         }
27
28         protected void Test (T t)
29         {
30                 Console.WriteLine (t);
31         }
32
33         public void Test ()
34         {
35                 Test (head.Item);
36                 Test (head.Next.Item);
37                 Test (GetFoo ().Item);
38                 Test (Foo.Item);
39         }
40
41         protected class Node<U>
42         {
43                 public readonly U Item;
44                 public readonly Node<U> Next;
45
46                 public Node (Node<U> next, U item)
47                 {
48                         this.Next = next;
49                         this.Item = item;
50                 }
51         }
52 }
53
54 class X
55 {
56         public static void Main ()
57         {
58                 Queue<int> queue = new Queue<int> (5, 9);
59                 queue.Test ();
60         }
61 }