Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-named-04.cs
1 using System;
2
3 struct S
4 {
5         public int Foo;
6 }
7
8 class Program
9 {
10         static void Foo2 (int a, ref int b)
11         {
12                 Console.WriteLine (a);
13                 Console.WriteLine (b);
14                 
15                 if (a != 0 || b != 0)
16                         throw new ApplicationException ();
17
18                 b = 500;
19         }
20         
21         static void Test<T> (T[] t)
22         {
23                 Foo (b: ref t[1], a: t[0]);
24         }
25         
26         static void Foo<T> (T a, ref T b)
27         {
28                 b = a;
29         }
30
31         public static int Main ()
32         {
33                 var a = new S [] { new S (), new S (), new S () };
34                 int i = 1;
35                 Foo2 (b: ref a[i].Foo, a: a[++i].Foo++);
36
37                 Console.WriteLine (a[0].Foo);
38                 Console.WriteLine (a[1].Foo);
39                 Console.WriteLine (a[2].Foo);
40                 
41                 if (a [0].Foo != 0)
42                         return 1;
43                 
44                 if (a [1].Foo != 500)
45                         return 2;
46                 
47                 if (a [2].Foo != 1)
48                         return 3;
49                 
50                 var array = new [] { 3, 4 };
51                 Test<int>(array);
52                 if (array [1] != 3)
53                         return 4;
54
55                 return 0;
56         }
57 }