Improve test
[mono.git] / mcs / tests / test-34.cs
1 //
2 // This test tests both how arguments are selected in the presence
3 // of ref/out modifiers and the params arguments.
4 //
5 using System;
6
7 public class Blah {
8         static int got;
9         
10         public static void Foo (ref int i, ref int j)
11         {
12                 got = 1;
13         }
14
15         public static int Bar (int j, params int [] args)
16         {
17                 got = 2;
18                 int total = 0;
19                 
20                 foreach (int i in args){
21                         Console.WriteLine ("My argument: " + i);
22                         total += i;
23                 }
24
25                 return total;
26         }
27
28         public static void Foo (int i, int j)
29         {
30                 got = 3;
31         }
32
33         static void In (ref int a)
34         {
35                 a++;
36         }
37
38         static void Out (ref int a)
39         {
40                 In (ref a);
41         }
42
43         static int AddArray (params int [] valores)
44         {
45                 int total = 0;
46                 
47                 for (int i = 0; i < valores.Length; i++)
48                         total += valores [i];
49
50                 return total;
51         }
52         
53         public static int Main ()
54         {
55                 int i = 1;
56                 int j = 2;
57
58                 int [] arr = new int [2] { 0, 1 };
59
60                 Foo (i, j);
61                 if (got != 3)
62                         return 1;
63                 
64                 Foo (ref i, ref j);
65                 if (got != 1)
66                         return 2;
67
68                 if (Bar (i, j, 5, 4, 3, 3, 2) != 19)
69                         return 4;
70
71                 //if (Bar (1, arr) != 1)
72                 //      return 5;
73                 
74                 if (got != 2)
75                         return 3;
76
77                 int k = 10;
78
79                 Out (ref k);
80                 if (k != 11)
81                         return 10;
82
83                 int [] arr2 = new int [2] {1, 2};
84
85                 if (AddArray (arr2) != 3)
86                         return 11;
87                 
88                 return  0;
89         }
90 }