Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / recursive-struct-arrays.cs
1 using System;
2
3 /* Test that the runtime can represent value types that have array fields that
4  * recursively refer to the same value type */
5
6 struct S1 {
7         static S1[][] foo;
8 }
9
10 struct S2 {
11         static S2[] foo;
12 }
13
14 struct S3a {
15         static S3b[] foo;
16 }
17
18 struct S3b {
19         static S3a[][] foo;
20 }
21
22 struct P<X> where X : struct {
23         static P<X>[][] foo;
24 }
25
26 public struct S4
27 {
28         private static S4[][] foo;
29
30         public static readonly S4 West = new S4(-1, 0);
31         public static readonly S4 East = new S4(1, 0);
32         public static readonly S4 North = new S4(0, 1);
33         public static readonly S4 South = new S4(0, -1);
34         public static readonly S4[] Directions = { North, South, East, West };
35
36         public readonly int x;
37         public readonly int z;
38
39         public S4(int x, int z)
40         {
41                 this.x = x;
42                 this.z = z;
43         }
44
45         public override string ToString()
46         {
47                 return string.Format("[{0}, {1}]", x, z);
48         }
49 }
50
51
52 class Program {
53         static int Main() {
54                 Console.WriteLine (typeof (S1).Name);
55                 Console.WriteLine (typeof (S2).Name);
56                 Console.WriteLine (typeof (S3a).Name);
57                 Console.WriteLine (typeof (S3b).Name);
58                 foreach (var s4 in S4.Directions) {
59                         Console.WriteLine (s4);
60                 }
61                 Console.WriteLine (typeof (P<S1>).Name);
62                 Console.WriteLine (typeof (P<int>).Name);
63                 return 0;
64         }
65 }