Merge pull request #5714 from alexischr/update_bockbuild
[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                 short [,] j = new short [4,2] { {0,1}, {2,3}, {4,5}, {6,7} };
18                 
19                 ushort [] a = { 4, 5, 6, 7 };
20
21                 long [,,] m = new long [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                 char [] c_arr = { 'A', 'B', 'C', 'M', 'R' };
33
34                 byte [] b_arr = { 0, 3, 8, 10, 21 };
35
36                 sbyte [] s_arr = { 10, 15, 30, 123 };
37                 
38                 int[,,] ints = new int[,,] { };
39                 
40                 if (a [2] != 6)
41                         return 1;
42
43                 if (s_arr [3] != 123)
44                         return 2;
45                 
46                 if (i [2] != 2)
47                         return 1;
48                 
49                 if (j [1,1] != 3)
50                         return 1;
51
52                 for (int t = 0; t < 4; ++t) {
53                         if (array [t] != t)
54                                 return 1;
55                         
56                         if (a [t] != (t + 4))
57                                 return 1;
58                 }
59
60                 if (bar [2,1] != 20)
61                         return 1;
62
63                 if (k [2] != 5)
64                         return 1;
65
66                 if (m [1,1,1] != 9)
67                         return 1;
68
69                 if (boo [0,1] != 11)
70                         return 1;
71
72                 if (f_array [0] != 1.23F)
73                         return 1;
74
75                 if (double_arr [1] != 90.1226)
76                         return 1;
77
78                 foreach (string s in names)
79                         Console.WriteLine ("Hello, " + s);
80
81                 if (names [0] != "Miguel")
82                         return 1;
83
84                 if (c_arr [4] != 'R')
85                         return 2;
86
87                 int count = 10;
88
89                 int [] x = new int [count];
90
91                 for (int idx = 0; idx < count; idx++)
92                         x [idx] = idx + 1;
93
94                 for (int idx = count; idx > 0; ){
95                         idx--;
96                         if (x [idx] != idx + 1)
97                                 return 12;
98                 }
99
100                 IntPtr [] arr = { new System.IntPtr (1) };
101                 if (arr [0] != (IntPtr) 1)
102                         return 13;
103
104                 IntPtr [] arr_i = { System.IntPtr.Zero };
105
106                 if (arr_i [0] != System.IntPtr.Zero)
107                         return 14;
108                 
109                 Console.WriteLine ("Array initialization test okay.");
110                                    
111                 return 0;
112         }
113 }