Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / vararg2.cs
1 using System;
2
3 public class main {
4     static int AddABunchOfShorts (__arglist)
5     {
6         int result = 0;
7
8         System.ArgIterator iter = new System.ArgIterator (__arglist);
9         int argCount = iter.GetRemainingCount();
10
11         for (int i = 0; i < argCount; i++) {
12             System.TypedReference typedRef = iter.GetNextArg();
13             result += (short)TypedReference.ToObject( typedRef );
14         }
15
16         return result;
17     }
18
19     static int AddABunchOfBytes (__arglist)
20     {
21         int result = 0;
22
23         System.ArgIterator iter = new System.ArgIterator (__arglist);
24         int argCount = iter.GetRemainingCount();
25
26         for (int i = 0; i < argCount; i++) {
27             System.TypedReference typedRef = iter.GetNextArg();
28             result += (byte)TypedReference.ToObject( typedRef );
29         }
30
31         return result;
32     }
33
34     public static int Main () {
35         if (AddABunchOfShorts (__arglist ((short)1, (short)2, (short)3)) != 6)
36             return 1;
37
38         if (AddABunchOfBytes (__arglist ((byte)4, (byte)5, (byte)6)) != 15)
39             return 2;
40
41         return 0;
42     }
43 }