2010-04-13 Sebastien Pouliot <sebastien@ximian.com>
[mono-project.git] / mcs / tests / test-269.cs
blob3b4eca845134fb7bc1265296c7ce1c7a22f2cb06
1 using System;
3 struct Result {
4 public int res;
5 // big enough that it won't be returned in registers
6 double duh;
7 long bah;
9 public Result (int val) {
10 res = val;
11 bah = val;
12 duh = val;
16 class Class1
18 static int AddABunchOfInts (__arglist)
20 int result = 0;
22 System.ArgIterator iter = new System.ArgIterator (__arglist);
23 int argCount = iter.GetRemainingCount();
25 for (int i = 0; i < argCount; i++) {
26 System.TypedReference typedRef = iter.GetNextArg();
27 result += (int)TypedReference.ToObject( typedRef );
30 return result;
33 static int AddASecondBunchOfInts (int a, __arglist)
35 int result = 0;
37 System.ArgIterator iter = new System.ArgIterator (__arglist);
38 int argCount = iter.GetRemainingCount();
40 for (int i = 0; i < argCount; i++) {
41 System.TypedReference typedRef = iter.GetNextArg();
42 result += (int)TypedReference.ToObject( typedRef );
45 return result;
48 static Result VtAddABunchOfInts (__arglist)
50 int result = 0;
52 System.ArgIterator iter = new System.ArgIterator (__arglist);
53 int argCount = iter.GetRemainingCount();
55 for (int i = 0; i < argCount; i++) {
56 System.TypedReference typedRef = iter.GetNextArg();
57 result += (int)TypedReference.ToObject( typedRef );
60 return new Result (result);
63 static Result VtAddASecondBunchOfInts (int a, __arglist)
65 int result = 0;
67 System.ArgIterator iter = new System.ArgIterator (__arglist);
68 int argCount = iter.GetRemainingCount();
70 for (int i = 0; i < argCount; i++) {
71 System.TypedReference typedRef = iter.GetNextArg();
72 result += (int)TypedReference.ToObject( typedRef );
75 return new Result (result);
78 int InstAddABunchOfInts (__arglist)
80 int result = 0;
82 System.ArgIterator iter = new System.ArgIterator (__arglist);
83 int argCount = iter.GetRemainingCount();
85 for (int i = 0; i < argCount; i++) {
86 System.TypedReference typedRef = iter.GetNextArg();
87 result += (int)TypedReference.ToObject( typedRef );
90 return result;
93 int InstAddASecondBunchOfInts (int a, __arglist)
95 int result = 0;
97 System.ArgIterator iter = new System.ArgIterator (__arglist);
98 int argCount = iter.GetRemainingCount();
100 for (int i = 0; i < argCount; i++) {
101 System.TypedReference typedRef = iter.GetNextArg();
102 result += (int)TypedReference.ToObject( typedRef );
105 return result;
108 Result InstVtAddABunchOfInts (__arglist)
110 int result = 0;
112 System.ArgIterator iter = new System.ArgIterator (__arglist);
113 int argCount = iter.GetRemainingCount();
115 for (int i = 0; i < argCount; i++) {
116 System.TypedReference typedRef = iter.GetNextArg();
117 result += (int)TypedReference.ToObject( typedRef );
120 return new Result (result);
123 Result InstVtAddASecondBunchOfInts (int a, __arglist)
125 int result = 0;
127 System.ArgIterator iter = new System.ArgIterator (__arglist);
128 int argCount = iter.GetRemainingCount();
130 for (int i = 0; i < argCount; i++) {
131 System.TypedReference typedRef = iter.GetNextArg();
132 result += (int)TypedReference.ToObject( typedRef );
135 return new Result (result);
138 static int Main (string[] args)
140 int result = AddABunchOfInts (__arglist ( 2, 3, 4 ));
141 Console.WriteLine ("Answer: {0}", result);
143 if (result != 9)
144 return 1;
146 result = AddASecondBunchOfInts (16, __arglist ( 2, 3, 4 ));
147 Console.WriteLine ("Answer: {0}", result);
149 if (result != 9)
150 return 2;
152 Class1 s = new Class1 ();
154 result = s.InstAddABunchOfInts (__arglist ( 2, 3, 4, 5 ));
155 Console.WriteLine ("Answer: {0}", result);
157 if (result != 14)
158 return 3;
160 result = s.InstAddASecondBunchOfInts (16, __arglist ( 2, 3, 4, 5, 6 ));
161 Console.WriteLine ("Answer: {0}", result);
163 if (result != 20)
164 return 4;
166 result = s.InstVtAddABunchOfInts (__arglist ( 2, 3, 4, 5 )).res;
167 Console.WriteLine ("Answer: {0}", result);
169 if (result != 14)
170 return 5;
172 result = s.InstVtAddASecondBunchOfInts (16, __arglist ( 2, 3, 4, 5, 6 )).res;
173 Console.WriteLine ("Answer: {0}", result);
175 if (result != 20)
176 return 6;
178 result = VtAddABunchOfInts (__arglist ( 2, 3, 4, 5, 1 )).res;
179 Console.WriteLine ("Answer: {0}", result);
181 if (result != 15)
182 return 7;
184 result = VtAddASecondBunchOfInts (16, __arglist ( 2, 3, 4, 5, 6, 1 )).res;
185 Console.WriteLine ("Answer: {0}", result);
187 if (result != 21)
188 return 8;
190 result = s.InstAddABunchOfInts (__arglist ( ));
191 if (result != 0)
192 return 9;
194 return 0;