eol
[mcs.git] / tests / test-44.cs
blobc1b896a58140acb7237d927dea3fdac7b51f89e4
1 //
2 // This test shows that the current way in which we handle blocks
3 // and statements is broken. The b [q,w] code is only executed 10
4 // times instead of a 100
5 //
6 using System;
8 class X {
10 static int dob (int [,]b)
12 int total = 0;
14 foreach (int i in b)
15 total += i;
17 return total;
21 // This tests typecasting from an object to an array of ints
22 // and then doing foreach
24 static int count (object o)
26 int total = 0;
28 foreach (int i in (int []) o)
29 total += i;
31 return total;
34 static int Main ()
36 int [,] b = new int [10,10];
38 for (int q = 0; q < 10; q++)
39 for (int w = 0; w < 10; w++)
40 b [q,w] = q * 10 + w;
42 if (dob (b) != 4950)
43 return 1;
45 int [] a = new int [10];
46 for (int i = 0; i < 10; i++)
47 a [i] = 2;
49 if (count (a) != 20)
50 return 2;
52 return 0;