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

gtest-181.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 95f8cd4129aff2cb72591d224e1ca08ea2fef9e1 (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
using System;
using System.Collections;

class X {
	static IEnumerator GetIt
	{
	    get {
		yield return 1;
		yield return 2;
		yield return 3;
	    }
	    set
	    {
	    }	    
	}
	
	IEnumerable this [int i]
	{
	    get {
		yield return 1*i;
		yield return 2*i;
		yield return 3*i;
	    }
	    set
	    {
	    }
	}

	public static int Main ()
	{
		IEnumerator e = GetIt;
		int total = 0;
		
		while (e.MoveNext ()){
			Console.WriteLine ("Value=" + e.Current);
			total += (int) e.Current;
		}

		if (total != 6)
			return 1;

		total = 0;
		X x = new X ();
		foreach (int i in x [2]){
			Console.WriteLine ("Value=" + i);
			total += i;
		}
		if (total != 12)
			return 2;
		
		return 0;
	}
}