Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-44.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa0367ea3c2d12be37b1240884f9fb08fe0f7485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// This test shows that the current way in which we handle blocks
// and statements is broken.  The b [q,w] code is only executed 10
// times instead of a 100
//
using System;

class X {

	static int dob (int [,]b)
	{
		int total = 0;
		
		foreach (int i in b)
			total += i;

		return total;
	}

	//
	// This tests typecasting from an object to an array of ints
	// and then doing foreach
	//
	static int count (object o)
	{
		int total = 0;

		foreach (int i in (int []) o)
			total += i;

		return total;
	}
	
	public static int Main ()
	{
		int [,] b = new int [10,10];

		for (int q = 0; q < 10; q++)
			for (int w = 0; w < 10; w++)
				b [q,w] = q * 10 + w;

		if (dob (b) != 4950)
			return 1;

		int [] a = new int [10];
		for (int i = 0; i < 10; i++)
			a [i] = 2;

		if (count (a) != 20)
			return 2;
		
		return 0;
	}
}