diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-11-27 19:02:37 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-11-29 14:02:24 +0300 |
commit | 33afa19ce339b8f002b21a113d67ff7aa626444a (patch) | |
tree | 8f47e71fc8d16dc6b486c84ddfa00459d5a6a762 /mcs/tests | |
parent | 425c62c5da0577be27d13591f3a17e837d290a43 (diff) |
[mcs] Implements C#7.1 default literal
Diffstat (limited to 'mcs/tests')
-rw-r--r-- | mcs/tests/test-default-01.cs | 52 | ||||
-rw-r--r-- | mcs/tests/test-default-02.cs | 21 | ||||
-rw-r--r-- | mcs/tests/ver-il-net_4_x.xml | 38 |
3 files changed, 111 insertions, 0 deletions
diff --git a/mcs/tests/test-default-01.cs b/mcs/tests/test-default-01.cs new file mode 100644 index 00000000000..823e33c451b --- /dev/null +++ b/mcs/tests/test-default-01.cs @@ -0,0 +1,52 @@ +// Compiler options: -langversion:latest + +static class X +{ + const int c1 = default; + const int c2 = default (int); + + public static void Main () + { + int a = default; + var b = (int) default; + const int c = default; + var d = new[] { 1, default }; + dynamic e = default; + int f = checked (default); + (int a, int b) g = (1, default); + var h = 1 != default; + var i = default == M4 (); + } + + static int M1 () + { + return default; + } + + static void M2 () + { + try { + throw new System.Exception (); + } catch (System.Exception) when (default) { + } + + if (default) { + } + } + + static void M3 (int x = default) + { + } + + static System.Func<int> M4 () + { + return () => default; + } +} +/* +enum E +{ + A = default, + B = default + 1 +} +*/
\ No newline at end of file diff --git a/mcs/tests/test-default-02.cs b/mcs/tests/test-default-02.cs new file mode 100644 index 00000000000..225da9b6d2b --- /dev/null +++ b/mcs/tests/test-default-02.cs @@ -0,0 +1,21 @@ +// Compiler options: -langversion:latest + +class C +{ + static void Main() + { + M (default, 1); + + M2 (default); + M2 (null); + } + + + static void M<T> (T x, T y) + { + } + + static void M2 (params object[] x) + { + } +}
\ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index c69461ef76b..4858d31c374 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -68527,6 +68527,44 @@ </method> </type> </test> + <test name="test-default-01.cs"> + <type name="X"> + <method name="Void Main()" attrs="150"> + <size>53</size> + </method> + <method name="Int32 M1()" attrs="145"> + <size>10</size> + </method> + <method name="Void M2()" attrs="145"> + <size>31</size> + </method> + <method name="Void M3(Int32)" attrs="145"> + <size>2</size> + </method> + <method name="System.Func`1[System.Int32] M4()" attrs="145"> + <size>38</size> + </method> + <method name="Int32 <M4>m__0()" attrs="145"> + <size>9</size> + </method> + </type> + </test> + <test name="test-default-02.cs"> + <type name="C"> + <method name="Void Main()" attrs="145"> + <size>8</size> + </method> + <method name="Void M[T](T, T)" attrs="145"> + <size>2</size> + </method> + <method name="Void M2(System.Object[])" attrs="145"> + <size>2</size> + </method> + <method name="Void .ctor()" attrs="6278"> + <size>7</size> + </method> + </type> + </test> <test name="test-dictinit-01.cs"> <type name="Program"> <method name="Int32 Main()" attrs="145"> |