2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / tests / gtest-448.cs
1 // Compiler options: -langversion:future
2
3 using System;
4 using System.Runtime.InteropServices;
5 using System.Reflection;
6
7 public class C
8 {
9         public static void TestA ([Optional][DefaultParameterValue (1)] int u)
10         {
11         }
12
13         public static void TestB (long u = 12)
14         {
15         }
16         
17         public static void TestC (decimal d = decimal.MaxValue)
18         {
19         }
20
21         public static int Main ()
22         {
23                 ParameterInfo[] info = typeof (C).GetMethod ("TestA").GetParameters ();
24
25                 if (info[0].DefaultValue.GetType () != typeof (int))
26                         return 1;
27
28                 if ((int) info[0].DefaultValue != 1)
29                         return 2;
30
31                 if (!info[0].IsOptional)
32                         return 3;
33
34                 info = typeof (C).GetMethod ("TestB").GetParameters ();
35
36                 if (info[0].DefaultValue.GetType () != typeof (int))
37                         return 11;
38
39                 if ((int) info[0].DefaultValue != 12)
40                         return 12;
41
42                 if (!info[0].IsOptional)
43                         return 13;
44
45                 info = typeof (C).GetMethod ("TestC").GetParameters ();
46
47                 if (info[0].DefaultValue.GetType () != typeof (decimal))
48                         return 21;
49
50                 if ((decimal) info[0].DefaultValue != decimal.MaxValue)
51                         return 22;
52
53                 if (!info[0].IsOptional)
54                         return 23;
55
56                 Console.WriteLine ("ok");
57                 return 0;
58         }
59 }