2 // This tests checks out field access to arrays
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 ()
25 static void FillSingle ()
29 for (i
= 0; i
< 10; i
++){
30 a_single
[i
].a
= i
+ 1;
34 static void FillDouble ()
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 ()
47 for (i
= 0; i
< 10; i
++){
48 o_single
[i
] = new Y ();
49 o_single
[i
].a
= (i
+ 1);
53 static void FillDoubleObject ()
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 ()
68 for (i
= 0; i
< 10; i
++){
69 if (a_single
[i
].a
!= i
+ 1)
75 static int TestDouble ()
79 for (i
= 0; i
< 10; i
++){
80 for (j
= 0; j
< 10; j
++)
81 if (a_double
[i
,j
].a
!= (i
*j
))
88 static int TestObjectSingle ()
92 for (i
= 0; i
< 10; i
++){
93 if ((int)(o_single
[i
].a
) != i
+ 1)
99 static int TestObjectDouble ()
103 for (i
= 0; i
< 10; i
++){
104 for (j
= 0; j
< 10; j
++)
105 if (((int)o_double
[i
,j
].a
) != (i
*j
))
112 public static int Main ()
119 if (TestSingle () != 0)
122 if (TestDouble () != 0)
125 if (TestObjectSingle () != 0)
128 if (TestObjectDouble () != 0)
131 Console
.WriteLine ("test passes");