Merge branch 'bugfix'
[mono.git] / mcs / tests / gtest-optional-04.cs
1 using System;
2
3 public struct S
4 {
5 }
6
7 public class C
8 {
9         static void Foo<T> (T t, T u = default (T))
10         {
11         }
12
13         static void TestParams (params int[] i)
14         {
15                 throw new ApplicationException ();
16         }
17
18         static void TestParams (int i = 4)
19         {
20         }
21
22         static void TestStruct (int? s = new int ())
23         {
24                 if (!s.HasValue)
25                         throw new ApplicationException ("TestStruct");
26         }
27         
28         static void TestStruct2 (S? s = new S? ())
29         {
30         }
31         
32         public string this [int i, string s = "test"] {
33                 get { return s; }
34                 set { value = s; }
35         }
36
37         public static int Main ()
38         {
39                 Foo ("f");
40                 Foo (2);
41                 Foo (2, 4);
42                 Foo<long> (2);
43                 Foo<string> ("2", "3");
44                 
45                 TestParams ();
46                 
47                 TestStruct ();
48                 TestStruct2 ();
49                 
50                 C c = new C ();
51                 if (c [1] != "test")
52                         return 1;
53                 
54                 c [3] = "value";
55                 
56                 return 0;
57         }
58 }