diff options
author | Bernhard Urban-Forster <lewurm@gmail.com> | 2020-04-23 21:47:35 +0300 |
---|---|---|
committer | Bernhard Urban-Forster <lewurm@gmail.com> | 2020-04-23 21:47:35 +0300 |
commit | b1d1496471d2cec500c26dd381068dac3f657ed0 (patch) | |
tree | ea88ada6ebd8e6073f9ae87a562aa869c665e718 | |
parent | 8e4b391d12046854737eb11a4b28dbb81bcaaac1 (diff) |
[enc] add LambdaFunc test (does not work)
-rw-r--r-- | mono/tests/enc/LambdaFunc.cs | 38 | ||||
-rw-r--r-- | mono/tests/enc/LambdaFunc_v1.cs | 38 | ||||
-rw-r--r-- | mono/tests/enc/Makefile.am | 1 |
3 files changed, 77 insertions, 0 deletions
diff --git a/mono/tests/enc/LambdaFunc.cs b/mono/tests/enc/LambdaFunc.cs new file mode 100644 index 00000000000..dd8845e31e5 --- /dev/null +++ b/mono/tests/enc/LambdaFunc.cs @@ -0,0 +1,38 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using MonoEnc; + +public class LambdaFunc { + public delegate int TestDelegate (int a); + + public static int Main (string []args) { + Assembly assm = typeof (LambdaFunc).Assembly; + var replacer = EncHelper.Make (); + + TestDelegate del = CreateDelegate (); + + int res = del (1); + if (res != 2) { + Console.WriteLine ("#1: " + res); + return 1; + } + + replacer.Update (assm); + + res = del (1); + if (res != 3) { + Console.WriteLine ("#2: " + res); + return 2; + } + + return 0; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static TestDelegate CreateDelegate () { + TestDelegate ret = delegate (int a) { return a + 1; }; + return ret; + } +} + diff --git a/mono/tests/enc/LambdaFunc_v1.cs b/mono/tests/enc/LambdaFunc_v1.cs new file mode 100644 index 00000000000..5f290c24c38 --- /dev/null +++ b/mono/tests/enc/LambdaFunc_v1.cs @@ -0,0 +1,38 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using MonoEnc; + +public class LambdaFunc { + public delegate int TestDelegate (int a); + + public static int Main (string []args) { + Assembly assm = typeof (LambdaFunc).Assembly; + var replacer = EncHelper.Make (); + + TestDelegate del = CreateDelegate (); + + int res = del (1); + if (res != 2) { + Console.WriteLine ("#1: " + res); + return 1; + } + + replacer.Update (assm); + + res = del (1); + if (res != 3) { + Console.WriteLine ("#2: " + res); + return 2; + } + + return 0; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static TestDelegate CreateDelegate () { + TestDelegate ret = delegate (int a) { return a + 2; }; + return ret; + } +} + diff --git a/mono/tests/enc/Makefile.am b/mono/tests/enc/Makefile.am index bcddbb91da7..d14219d95b4 100644 --- a/mono/tests/enc/Makefile.am +++ b/mono/tests/enc/Makefile.am @@ -4,6 +4,7 @@ ROSLYNILDIFF ?=/Users/lewurm/work/roslynildiff/bin/Debug/roslynildiff.exe TESTS_REGULAR := \ AddStaticMethod.dll \ CallExisting.dll \ + LambdaFunc.dll \ ReplaceMethod.dll \ ReplaceMethodOften.dll \ ReplacePrivateVirtualMethod.dll \ |