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

test-async-86.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f8f71aae49b53e081f981f206986c1f759481dd (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Threading.Tasks;

public class Program
{
	string Data { 
		get {
			return data;
		}
		set {
			++setter_called;
			data = value;
		}
	}

	int setter_called;
	string data = "init-";

	string this [string arg] {
		get {
			return i_data;
		}
		set {
			++i_setter_called;
			i_data = value;
		}
	}

	int i_setter_called;
	string i_data = "init2-";

	public static int Main()
	{
		var p = new Program ();
		p.TestProperty ().Wait ();
		if (p.data != "init-nxa123z") {
			return 1;
		}

		if (p.setter_called != 1)
			return 2;

		p.TestIndexer ().Wait ();

		if (p.i_data != "init2-nxa123z") {
			return 3;
		}

		if (p.i_setter_called != 1)
			return 4;

		return 0;
	}

	async Task TestProperty ()
	{
		Data += "n" + await StringValue () + "a" + 123.ToString () + "z";
	}

	async Task TestIndexer ()
	{
		string arg = "foo";
		this[arg] += "n" + await StringValue () + "a" + 123.ToString () + "z";
	}

	async Task<string> StringValue ()
	{
		await Task.Yield ();
		return "x";
	}
}