Merge pull request #1861 from saper/home-override
[mono-project.git] / mcs / tests / test-66.cs
blobd7415861acffdff4bb18668c5fa3d569fe220b86
1 //
2 // This tests checks out field access to arrays
3 //
4 using System;
6 struct A {
7 public int a;
10 class Y {
11 public object a;
14 class X {
15 static A [] a_single = new A [10];
16 static A [,] a_double = new A [10,10];
17 static Y [] o_single = new Y [10];
18 static Y [,] o_double = new Y [10,10];
20 static void FillOne ()
22 a_single [0].a = 1;
25 static void FillSingle ()
27 int i;
29 for (i = 0; i < 10; i++){
30 a_single [i].a = i + 1;
34 static void FillDouble ()
36 int i, j;
38 for (i = 0; i < 10; i++)
39 for (j = 0; j < 10; j++)
40 a_double [i,j].a = i * j;
43 static void FillObject ()
45 int i;
47 for (i = 0; i < 10; i++){
48 o_single [i] = new Y ();
49 o_single [i].a = (i + 1);
53 static void FillDoubleObject ()
55 int i, j;
57 for (i = 0; i < 10; i++)
58 for (j = 0; j < 10; j++){
59 o_double [i,j] = new Y ();
60 o_double [i,j].a = i * j;
64 static int TestSingle ()
66 int i;
68 for (i = 0; i < 10; i++){
69 if (a_single [i].a != i + 1)
70 return 1;
72 return 0;
75 static int TestDouble ()
77 int i, j;
79 for (i = 0; i < 10; i++){
80 for (j = 0; j < 10; j++)
81 if (a_double [i,j].a != (i *j))
82 return 2;
85 return 0;
88 static int TestObjectSingle ()
90 int i;
92 for (i = 0; i < 10; i++){
93 if ((int)(o_single [i].a) != i + 1)
94 return 1;
96 return 0;
99 static int TestObjectDouble ()
101 int i, j;
103 for (i = 0; i < 10; i++){
104 for (j = 0; j < 10; j++)
105 if (((int)o_double [i,j].a) != (i *j))
106 return 2;
109 return 0;
112 public static int Main ()
114 FillSingle ();
115 FillDouble ();
116 FillObject ();
117 FillDoubleObject ();
119 if (TestSingle () != 0)
120 return 1;
122 if (TestDouble () != 0)
123 return 2;
125 if (TestObjectSingle () != 0)
126 return 3;
128 if (TestObjectDouble () != 0)
129 return 4;
131 Console.WriteLine ("test passes");
132 return 0;