From 1498631c3358aaa363088a129a53c0efbd0dca9d Mon Sep 17 00:00:00 2001 From: Viacheslav Nikolaev Date: Mon, 6 Jun 2016 14:14:10 +0300 Subject: [PATCH] Delegate ABI Test Detects issue #5275 --- .../cti/system/delegate/DelegateABI.csproj | 49 +++++++++++++ .../cti/system/delegate/delegateabi.cs | 68 +++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 tests/src/CoreMangLib/cti/system/delegate/DelegateABI.csproj create mode 100644 tests/src/CoreMangLib/cti/system/delegate/delegateabi.cs diff --git a/tests/src/CoreMangLib/cti/system/delegate/DelegateABI.csproj b/tests/src/CoreMangLib/cti/system/delegate/DelegateABI.csproj new file mode 100644 index 000000000000..8e0bb0d3ff3d --- /dev/null +++ b/tests/src/CoreMangLib/cti/system/delegate/DelegateABI.csproj @@ -0,0 +1,49 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + true + false + BuildAndRun + 1 + + + + + + + + + False + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/CoreMangLib/cti/system/delegate/delegateabi.cs b/tests/src/CoreMangLib/cti/system/delegate/delegateabi.cs new file mode 100644 index 000000000000..e13ccafb8eaf --- /dev/null +++ b/tests/src/CoreMangLib/cti/system/delegate/delegateabi.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace ClassLibrary +{ + public class test + { + public delegate float FloatTest(float a); + + static float testfloat(float a) + { + if(a != -1.1f) + { + throw new Exception(); + } + return -2.2f; + } + + public delegate int IntTest(int a); + + static int testint(int a) + { + if(a != -1) + { + throw new Exception(); + } + return -2; + } + + static int Main(string[] args) + { + try + { + IntTest inttest = testint; + int r = inttest(-1); + if (r != -2) + { + Console.WriteLine("FAIL - int return value mismatch"); + return 101; + } + } + catch (Exception) + { + Console.WriteLine("FAIL - int argument value mismatch"); + return 102; + } + try + { + FloatTest floattest = testfloat; + float r = floattest(-1.1f); + if (r != -2.2f) + { + Console.WriteLine("FAIL - float return value mismatch"); + return 103; + } + } + catch (Exception) + { + Console.WriteLine("FAIL - float argument value mismatch"); + return 104; + } + return 100; + } + } +}