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

test-580.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1712837a7d43ac433de56564adb43b0daf8f8e6 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;

public class Bla {
	
	public static void BuildNode (ref string label)
	{
		string s = "a";
		label += s + s + s + s;
	}
	
	public static void BuildNode (ref string[] label)
	{
		string s = "a";
		int idx = 0;
		label[idx++] += s + s + s + s;
	}
	
	public static void BuildNode_B (ref object label)
	{
		string s = "b";
		label += s + s;
	}
	
	public static string BuildNode_C (ref string label)
	{
		string[] a = new string [2];
		int i = 0;
		a [0] = "a";
		string s = "b";

		a [i++] += label + s + s + s;
		return a [i - 1];
	}
	
	public static string BuildNode_D ()
	{
		System.Collections.ArrayList values = new System.Collections.ArrayList ();
		for (int i = 0; i < 6; i++)
			values.Add (i);
		string[] strs = new string [values.Count];
		int idx = 0;
		foreach (int val in values) {
			strs [idx] = "Value:";
			strs [idx++] += val.ToString ();
		}
		
		return strs [5];
	}
	
	public static void BuildNode_E (ref string[,] label)
	{
		string s = "a";
		int idx = 0;
		label = new string [1, 1];
		label[idx++, idx - 1] += s + s + s + s;
	}
	
	static bool Test_Object ()
	{
		int a = 0;
		object[] o_a = new string[] { "A" };
		o_a [a++] += "Z";
		if ((string) o_a [0] != "AZ")
			return false;
		
		a = 0;
		object[,] o_a2 = new string[,] { { "X" } };
		o_a2[a++, 0] += "Z";
		if ((string) o_a2 [0, 0] != "XZ")
			return false;
		
		return true;
	}
	
	static bool Test_Decimal ()
	{
		decimal[,] da = new decimal[,] { { 5, 6 } };
		da[0,0] = 6.7m;
		da[0,0] += 1.2m;
		
		if (da [0,0] != 7.9m)
			return false;
		
		return true;
	}
	
	public static int Main ()
	{
		String str = "test";
		
		BuildNode (ref str);
		Console.WriteLine (str);
		if (str != "testaaaa")
			return 1;
		
		object ostr = "test";
		BuildNode_B (ref ostr);
		Console.WriteLine (ostr);
		if (ostr.ToString () != "testbb")
			return 2;
		
		str = "test";
		string res = BuildNode_C (ref str);
		Console.WriteLine (str);
		if (str != "test")
			return 3;
		
		Console.WriteLine (res);
		if (res != "atestbbb")
			return 4;
		
		string[] sa = new string [1];
		BuildNode (ref sa);
		Console.WriteLine (sa [0]);
		if (sa [0] != "aaaa")
			return 5;
		
		str = BuildNode_D ();
		Console.WriteLine (str);
		if (str != "Value:5")
			return 6;
		
		string[,] sa2 = null;
		BuildNode_E (ref sa2);
		Console.WriteLine (sa2 [0, 0]);
		if (sa2 [0,0] != "aaaa")
			return 7;
		
		if (!Test_Object ())
			return 8;

		if (!Test_Decimal ())
			return 9;

		return 0;
	}
}