2002-01-08 Miguel de Icaza <miguel@ximian.com>
[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         public static int Main ()
44         {
45                 int i = 1;
46                 int j = 2;
47
48                 int [] arr = new int [2] { 0, 1 };
49
50                 Foo (i, j);
51                 if (got != 3)
52                         return 1;
53                 
54                 Foo (ref i, ref j);
55                 if (got != 1)
56                         return 2;
57
58                 if (Bar (i, j, 5, 4, 3, 3, 2) != 19)
59                         return 4;
60
61                 //if (Bar (1, arr) != 1)
62                 //      return 5;
63                 
64                 if (got != 2)
65                         return 3;
66
67                 int k = 10;
68
69                 Out (ref k);
70                 if (k != 11)
71                         return 10;
72                 
73                 return  0;
74         }
75 }