2001-12-23 Ravi Pratap <ravi@ximian.com>
[mono.git] / mcs / tests / test-45.cs
1 using System;
2
3 public class Blah {
4
5         private static int[] array = {0, 1, 2, 3};
6
7         private static int [,] bar = { {0,1}, {4,5}, {10,20} };
8
9         static string [] names = {
10                 "Miguel", "Paolo", "Dietmar", "Dick", "Ravi"
11         };
12
13         public static int Main ()
14         {
15                 int [] i = new int [4] { 0, 1, 2, 3 };
16
17                 int [,] j = new int [4,2] { {0,1}, {2,3}, {4,5}, {6,7} };
18                 
19                 int [] a = { 4, 5, 6, 7 };
20
21                 int [,,] m = new int [2,3,2] {{{0,1}, {2,3}, {4,5}}, {{6,7}, {8,9}, {10,11}}};
22
23                 int foo = 1;
24                 int [] k = new int [] { foo, foo+1, foo+4 };
25
26                 int [,] boo = new int [,] {{foo, foo+10}, {foo+3, foo+10}};
27
28                 float [] f_array = new float [] { 1.23F, 4.5F, 6.24F };
29
30                 double [] double_arr = new double [] { 34.4567, 90.1226, 54.9823 };
31         
32
33                 if (i [2] != 2)
34                         return 1;
35                 
36                 if (j [1,1] != 3)
37                         return 1;
38
39                 for (int t = 0; t < 4; ++t) {
40                         if (array [t] != t)
41                                 return 1;
42                         
43                         if (a [t] != (t + 4))
44                                 return 1;
45                 }
46
47                 if (bar [2,1] != 20)
48                         return 1;
49
50                 if (k [2] != 5)
51                         return 1;
52
53                 if (m [1,1,1] != 9)
54                         return 1;
55
56                 if (boo [0,1] != 11)
57                         return 1;
58
59                 if (f_array [0] != 1.23F)
60                         return 1;
61
62                 if (double_arr [1] != 90.1226)
63                         return 1;
64
65                 foreach (string s in names)
66                         Console.WriteLine ("Hello, " + s);
67
68                 if (names [0] != "Miguel")
69                         return 1;
70
71                 int count = 10;
72
73                 int [] x = new int [count];
74
75                 for (int idx = 0; idx < count; idx++)
76                         x [idx] = idx + 1;
77
78                 for (int idx = count; idx > 0; ){
79                         idx--;
80                         if (x [idx] != idx + 1)
81                                 return 12;
82                 }
83                 Console.WriteLine ("Array initialization test okay.");
84                                    
85                 return 0;
86         }
87 }