Add test for dotnet/coreclr#18362
authorCarol Eidt <carol.eidt@microsoft.com>
Thu, 28 Jun 2018 23:10:55 +0000 (16:10 -0700)
committerCarol Eidt <carol.eidt@microsoft.com>
Thu, 28 Jun 2018 23:22:39 +0000 (16:22 -0700)
Also add to the arm & arm64 tests.lst

Commit migrated from https://github.com/dotnet/coreclr/commit/b9db2cfc342593ef37c9c17d427bd9df86f686f3

src/coreclr/tests/arm/Tests.lst
src/coreclr/tests/arm64/Tests.lst
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj [new file with mode: 0644]

index db55677..eac6ca4 100644 (file)
@@ -94804,3 +94804,11 @@ MaxAllowedDurationSeconds=600
 Categories=EXPECTED_PASS
 HostStyle=0
 
+[GitHub_18362.cmd_11911]
+RelativePath=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362\GitHub_18362.cmd
+WorkingDir=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362
+Expected=0
+MaxAllowedDurationSeconds=600
+Categories=EXPECTED_PASS
+HostStyle=0
+
index 4d75928..9d97229 100644 (file)
@@ -94827,3 +94827,11 @@ Expected=0
 MaxAllowedDurationSeconds=600
 Categories=EXPECTED_PASS
 HostStyle=0
+[GitHub_18362.cmd_12231]
+RelativePath=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362\GitHub_18362.cmd
+WorkingDir=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362
+Expected=0
+MaxAllowedDurationSeconds=600
+Categories=EXPECTED_PASS
+HostStyle=0
+
diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs b/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs
new file mode 100644 (file)
index 0000000..695ca20
--- /dev/null
@@ -0,0 +1,112 @@
+// 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;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+// This is a struct that will be passed as a split struct
+struct S
+{
+    public double d1;
+    public double d2;
+};
+
+static class GitHub_18362
+{
+    private static bool AreSameInfinity(double d1, double d2)
+    {
+        return
+            double.IsNegativeInfinity(d1) == double.IsNegativeInfinity(d2) &&
+            double.IsPositiveInfinity(d1) == double.IsPositiveInfinity(d2);
+    }
+
+    private static bool IsDiffTolerable(double d1, double d2)
+    {
+        if (double.IsInfinity(d1))
+        {
+            return AreSameInfinity(d1, d2 * 10);
+        }
+        if (double.IsInfinity(d2))
+        {
+            return AreSameInfinity(d1 * 10, d2);
+        }
+        double diffRatio = (d1 - d2) / d1;
+        diffRatio *= Math.Pow(10, 6);
+        return Math.Abs(diffRatio) < 1;
+    }
+
+    private static void VerifyRealImaginaryProperties(Complex complex, double real, double imaginary, [CallerLineNumber] int lineNumber = 0)
+    {
+        if (!real.Equals(complex.Real) && !IsDiffTolerable(complex.Real, real))
+        {
+            Console.WriteLine("Failure at line {0}. Expected real: {1}. Actual real: {2}", lineNumber, real, complex.Real);
+            throw new Exception();
+        }
+        if (!imaginary.Equals(complex.Imaginary) && !IsDiffTolerable(complex.Imaginary, imaginary))
+        {
+            Console.WriteLine("Failure at line {0}. Expected imaginary: {1}. Actual imaginary: {2}", lineNumber, imaginary, complex.Imaginary);
+            throw new Exception();
+        }
+    }
+
+
+    private static void VerifyMagnitudePhaseProperties(Complex complex, double magnitude, double phase, [CallerLineNumber] int lineNumber = 0)
+    {
+        // The magnitude (m) of a complex number (z = x + yi) is the absolute value - |z| = sqrt(x^2 + y^2)
+        // Verification is done using the square of the magnitude since m^2 = x^2 + y^2
+        double expectedMagnitudeSquared = magnitude * magnitude;
+        double actualMagnitudeSquared = complex.Magnitude * complex.Magnitude;
+
+        if (!expectedMagnitudeSquared.Equals(actualMagnitudeSquared) && !IsDiffTolerable(actualMagnitudeSquared, expectedMagnitudeSquared))
+        {
+            Console.WriteLine("Failure at line {0}. Expected magnitude squared: {1}. Actual magnitude squared: {2}", lineNumber, expectedMagnitudeSquared, actualMagnitudeSquared);
+            throw new Exception();
+        }
+
+        if (double.IsNaN(magnitude))
+        {
+            phase = double.NaN;
+        }
+        else if (magnitude == 0)
+        {
+            phase = 0;
+        }
+        else if (magnitude < 0)
+        {
+            phase += (phase < 0) ? Math.PI : -Math.PI;
+        }
+
+        if (!phase.Equals(complex.Phase) && !IsDiffTolerable(complex.Phase, phase))
+        {
+            Console.WriteLine("Failure at line {0}. Expected phase: {1}. Actual phase: {2}", lineNumber, phase, complex.Phase);
+            throw new Exception();
+        }
+    }
+
+    public static void Conjugate(double real, double imaginary)
+    {
+        int returnVal = 100;
+
+        var complex = new Complex(real, imaginary);
+        Complex result = Complex.Conjugate(complex);
+
+        VerifyRealImaginaryProperties(result, real, -imaginary);
+        VerifyMagnitudePhaseProperties(result, complex.Magnitude, -complex.Phase);
+    }
+
+    [MethodImpl(MethodImplOptions.NoOptimization)]
+    static int Main()
+    {
+        try
+        {
+            Conjugate(2.0, 3.0);
+        }
+        catch (Exception e)
+        {
+            return -1;
+        }
+        return 100;
+    }
+}
diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj b/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj
new file mode 100644 (file)
index 0000000..ea8e8a7
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType></DebugType>
+    <Optimize>True</Optimize>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+  <PropertyGroup>
+    <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_TailcallStress=1
+]]></CLRTestBatchPreCommands>
+  <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_TailcallStress=1
+]]></BashCLRTestPreCommands>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>