[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / tests / test-580.cs
1 using System;
2
3 public class Bla {
4         
5         public static void BuildNode (ref string label)
6         {
7                 string s = "a";
8                 label += s + s + s + s;
9         }
10         
11         public static void BuildNode (ref string[] label)
12         {
13                 string s = "a";
14                 int idx = 0;
15                 label[idx++] += s + s + s + s;
16         }
17         
18         public static void BuildNode_B (ref object label)
19         {
20                 string s = "b";
21                 label += s + s;
22         }
23         
24         public static string BuildNode_C (ref string label)
25         {
26                 string[] a = new string [2];
27                 int i = 0;
28                 a [0] = "a";
29                 string s = "b";
30
31                 a [i++] += label + s + s + s;
32                 return a [i - 1];
33         }
34         
35         public static string BuildNode_D ()
36         {
37                 System.Collections.ArrayList values = new System.Collections.ArrayList ();
38                 for (int i = 0; i < 6; i++)
39                         values.Add (i);
40                 string[] strs = new string [values.Count];
41                 int idx = 0;
42                 foreach (int val in values) {
43                         strs [idx] = "Value:";
44                         strs [idx++] += val.ToString ();
45                 }
46                 
47                 return strs [5];
48         }
49         
50         public static void BuildNode_E (ref string[,] label)
51         {
52                 string s = "a";
53                 int idx = 0;
54                 label = new string [1, 1];
55                 label[idx++, idx - 1] += s + s + s + s;
56         }
57         
58         static bool Test_Object ()
59         {
60                 int a = 0;
61                 object[] o_a = new string[] { "A" };
62                 o_a [a++] += "Z";
63                 if ((string) o_a [0] != "AZ")
64                         return false;
65                 
66                 a = 0;
67                 object[,] o_a2 = new string[,] { { "X" } };
68                 o_a2[a++, 0] += "Z";
69                 if ((string) o_a2 [0, 0] != "XZ")
70                         return false;
71                 
72                 return true;
73         }
74         
75         static bool Test_Decimal ()
76         {
77                 decimal[,] da = new decimal[,] { { 5, 6 } };
78                 da[0,0] = 6.7m;
79                 da[0,0] += 1.2m;
80                 
81                 if (da [0,0] != 7.9m)
82                         return false;
83                 
84                 return true;
85         }
86         
87         public static int Main ()
88         {
89                 String str = "test";
90                 
91                 BuildNode (ref str);
92                 Console.WriteLine (str);
93                 if (str != "testaaaa")
94                         return 1;
95                 
96                 object ostr = "test";
97                 BuildNode_B (ref ostr);
98                 Console.WriteLine (ostr);
99                 if (ostr.ToString () != "testbb")
100                         return 2;
101                 
102                 str = "test";
103                 string res = BuildNode_C (ref str);
104                 Console.WriteLine (str);
105                 if (str != "test")
106                         return 3;
107                 
108                 Console.WriteLine (res);
109                 if (res != "atestbbb")
110                         return 4;
111                 
112                 string[] sa = new string [1];
113                 BuildNode (ref sa);
114                 Console.WriteLine (sa [0]);
115                 if (sa [0] != "aaaa")
116                         return 5;
117                 
118                 str = BuildNode_D ();
119                 Console.WriteLine (str);
120                 if (str != "Value:5")
121                         return 6;
122                 
123                 string[,] sa2 = null;
124                 BuildNode_E (ref sa2);
125                 Console.WriteLine (sa2 [0, 0]);
126                 if (sa2 [0,0] != "aaaa")
127                         return 7;
128                 
129                 if (!Test_Object ())
130                         return 8;
131
132                 if (!Test_Decimal ())
133                         return 9;
134
135                 return 0;
136         }
137 }