2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / tests / test-named-02.cs
1 // Compiler options: -langversion:future
2
3 using System;
4
5 class A
6 {
7         public int id;
8         
9         public int this [int i] {
10                 set { Console.WriteLine ("set= " + i); id = value; }
11                 get { Console.WriteLine ("get= " + i); return id; }
12         }
13 }
14
15 struct MyPoint
16 {
17         public MyPoint (int x, int y)
18         {
19                 X = x;
20                 Y = y;
21         }
22         
23         public int X, Y;
24 }
25
26 class C
27 {
28         static decimal Foo (decimal t, decimal a)
29         {
30                 return a;
31         }
32         
33         static string Bar (int a = 1, string s = "2", char c = '3')
34         {
35                 return a.ToString () + s + c;
36         }
37
38         static int Test (int a, int b)
39         {
40                 Console.WriteLine ("{0} {1}", a, b);
41                 return a * 3 + b * 7;
42         }
43         
44         public static int Main ()
45         {
46                 int h;
47                 if (Foo (a : h = 9, t : 3) != 9)
48                         return 1;
49                 
50                 if (h != 9)
51                         return 2;
52                 
53                 if (Bar (a : 1, s : "x", c : '2') != "1x2")
54                         return 3;
55                 
56                 if (Bar (s : "x") != "1x3")
57                         return 4;
58                 
59                 int i = 1;
60                 if (Test (a: i++, b: i++) != 17)
61                         return 5;
62                 
63                 if (i != 3)
64                         return 6;
65                 
66                 i = 1;
67                 if (Test (b: i++, a: i++) != 13)
68                         return 7;
69                 
70                 A a = new A ();
71                 i = 5;
72                 a [i:i++]++;
73                 
74                 if (a.id != 1)
75                         return 8;
76                 
77                 if (i != 6)
78                         return 9;
79                 
80                 MyPoint mp = new MyPoint (y : -1, x : 5);
81                 if (mp.Y != -1)
82                         return 10;
83                 
84                 Console.WriteLine ("ok");
85                 return 0;
86         }
87 }