Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gtest-optional-01.cs
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Reflection;
4
5 public class C
6 {
7         public static void TestA ([Optional][DefaultParameterValue (1)] int u)
8         {
9         }
10
11         public static void TestB (long u = 12)
12         {
13         }
14         
15         public static void TestC (decimal d = decimal.MaxValue)
16         {
17         }
18
19         public static int Main ()
20         {
21                 ParameterInfo[] info = typeof (C).GetMethod ("TestA").GetParameters ();
22
23                 if (info[0].DefaultValue.GetType () != typeof (int))
24                         return 1;
25
26                 if ((int) info[0].DefaultValue != 1)
27                         return 2;
28
29                 if (!info[0].IsOptional)
30                         return 3;
31
32                 info = typeof (C).GetMethod ("TestB").GetParameters ();
33
34                 if (info[0].DefaultValue.GetType () != typeof (long))
35                         return 11;
36
37                 if ((long) info[0].DefaultValue != 12)
38                         return 12;
39
40                 if (!info[0].IsOptional)
41                         return 13;
42
43                 info = typeof (C).GetMethod ("TestC").GetParameters ();
44
45                 if (info[0].DefaultValue.GetType () != typeof (decimal))
46                         return 21;
47
48                 if ((decimal) info[0].DefaultValue != decimal.MaxValue)
49                         return 22;
50
51                 if (!info[0].IsOptional)
52                         return 23;
53
54                 Console.WriteLine ("ok");
55                 return 0;
56         }
57 }