From 59db2cef21998c9680670a95939e77ee29ebc595 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 5 Dec 2017 19:49:20 -0800 Subject: [PATCH] Add tests for Math.Ceiling, Floor, and Round. --- tests/src/JIT/Intrinsics/MathCeilingDouble.cs | 172 +++++++++++++++++++++ .../src/JIT/Intrinsics/MathCeilingDouble_r.csproj | 34 ++++ .../src/JIT/Intrinsics/MathCeilingDouble_ro.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathCeilingSingle.cs | 172 +++++++++++++++++++++ .../src/JIT/Intrinsics/MathCeilingSingle_r.csproj | 34 ++++ .../src/JIT/Intrinsics/MathCeilingSingle_ro.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathFloorDouble.cs | 172 +++++++++++++++++++++ tests/src/JIT/Intrinsics/MathFloorDouble_r.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathFloorDouble_ro.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathFloorSingle.cs | 172 +++++++++++++++++++++ tests/src/JIT/Intrinsics/MathFloorSingle_r.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathFloorSingle_ro.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathRoundDouble.cs | 172 +++++++++++++++++++++ tests/src/JIT/Intrinsics/MathRoundDouble_r.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathRoundDouble_ro.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathRoundSingle.cs | 172 +++++++++++++++++++++ tests/src/JIT/Intrinsics/MathRoundSingle_r.csproj | 34 ++++ tests/src/JIT/Intrinsics/MathRoundSingle_ro.csproj | 34 ++++ 18 files changed, 1440 insertions(+) create mode 100644 tests/src/JIT/Intrinsics/MathCeilingDouble.cs create mode 100644 tests/src/JIT/Intrinsics/MathCeilingDouble_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathCeilingDouble_ro.csproj create mode 100644 tests/src/JIT/Intrinsics/MathCeilingSingle.cs create mode 100644 tests/src/JIT/Intrinsics/MathCeilingSingle_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathCeilingSingle_ro.csproj create mode 100644 tests/src/JIT/Intrinsics/MathFloorDouble.cs create mode 100644 tests/src/JIT/Intrinsics/MathFloorDouble_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathFloorDouble_ro.csproj create mode 100644 tests/src/JIT/Intrinsics/MathFloorSingle.cs create mode 100644 tests/src/JIT/Intrinsics/MathFloorSingle_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathFloorSingle_ro.csproj create mode 100644 tests/src/JIT/Intrinsics/MathRoundDouble.cs create mode 100644 tests/src/JIT/Intrinsics/MathRoundDouble_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathRoundDouble_ro.csproj create mode 100644 tests/src/JIT/Intrinsics/MathRoundSingle.cs create mode 100644 tests/src/JIT/Intrinsics/MathRoundSingle_r.csproj create mode 100644 tests/src/JIT/Intrinsics/MathRoundSingle_ro.csproj diff --git a/tests/src/JIT/Intrinsics/MathCeilingDouble.cs b/tests/src/JIT/Intrinsics/MathCeilingDouble.cs new file mode 100644 index 0000000..9893e99 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingDouble.cs @@ -0,0 +1,172 @@ +// 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 MathCeilingDoubleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const double constantValue = 0.0; + + public static double staticValue = 1.1; + + public static double[] staticValueArray = new double[] + { + 2.2, + 3.3, + 4.4 + }; + + public double instanceValue = 5.5; + + public double[] instanceValueArray = new double[] + { + 6.6, + 7.7, + 8.8 + }; + + unsafe static int Main(string[] args) + { + double localValue = 9.9; + + var program = new Program(); + + if (Math.Round(constantValue) != 0.0) + { + Console.WriteLine("Math.Round of a constant value failed"); + return Fail; + } + + if (Math.Round(staticValue) != 1.0) + { + Console.WriteLine("Math.Round of a static value failed"); + return Fail; + } + + fixed (double* pStaticValue = &staticValue) + { + if (Math.Round(*pStaticValue) != 1.0) + { + Console.WriteLine("Math.Round of an addressed static value failed"); + return Fail; + } + } + + if (Math.Round(staticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Round of a static value array (index 0) failed"); + return Fail; + } + + if (Math.Round(staticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Round of a static value array (index 1) failed"); + return Fail; + } + + if (Math.Round(staticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Round of a static value array (index 2) failed"); + return Fail; + } + + fixed (double* pStaticValueArray = &staticValueArray[0]) + { + if (Math.Round(pStaticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 0) failed"); + return Fail; + } + + if (Math.Round(pStaticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 1) failed"); + return Fail; + } + + if (Math.Round(pStaticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (Math.Round(program.instanceValue) != 6.0) + { + Console.WriteLine("Math.Round of an instance value failed"); + return Fail; + } + + fixed (double* pInstanceValue = &program.instanceValue) + { + if (Math.Round(*pInstanceValue) != 6.0) + { + Console.WriteLine("Math.Round of an addressed instance value failed"); + return Fail; + } + } + + if (Math.Round(program.instanceValueArray[0]) != 7.0) + { + Console.WriteLine("Math.Round of an instance value array (index 0) failed"); + return Fail; + } + + if (Math.Round(program.instanceValueArray[1]) != 8.0) + { + Console.WriteLine("Math.Round of an instance value array (index 1) failed"); + return Fail; + } + + if (Math.Round(program.instanceValueArray[2]) != 9.0) + { + Console.WriteLine("Math.Round of an instance value array (index 2) failed"); + return Fail; + } + + fixed (double* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (Math.Round(pInstanceValueArray[0]) != 7.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (Math.Round(pInstanceValueArray[1]) != 8.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (Math.Round(pInstanceValueArray[2]) != 9.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (Math.Round(localValue) != 10.0) + { + Console.WriteLine("Math.Round of a local value failed"); + return Fail; + } + + double* pLocalValue = &localValue; + + if (Math.Round(*pLocalValue) != 10.0) + { + Console.WriteLine("Math.Round of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathCeilingDouble_r.csproj b/tests/src/JIT/Intrinsics/MathCeilingDouble_r.csproj new file mode 100644 index 0000000..ca3df05 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingDouble_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathCeilingDouble_ro.csproj b/tests/src/JIT/Intrinsics/MathCeilingDouble_ro.csproj new file mode 100644 index 0000000..0b912dc --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingDouble_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathCeilingSingle.cs b/tests/src/JIT/Intrinsics/MathCeilingSingle.cs new file mode 100644 index 0000000..b1db0c0 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingSingle.cs @@ -0,0 +1,172 @@ +// 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 MathCeilingSingleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const float constantValue = 0.0f; + + public static float staticValue = 1.1f; + + public static float[] staticValueArray = new float[] + { + 2.2f, + 3.3f, + 4.4f + }; + + public float instanceValue = 5.5f; + + public float[] instanceValueArray = new float[] + { + 6.6f, + 7.7f, + 8.8f + }; + + unsafe static int Main(string[] args) + { + float localValue = 9.9f; + + var program = new Program(); + + if (MathF.Round(constantValue) != 0.0f) + { + Console.WriteLine("MathF.Round of a constant value failed"); + return Fail; + } + + if (MathF.Round(staticValue) != 1.0f) + { + Console.WriteLine("MathF.Round of a static value failed"); + return Fail; + } + + fixed (float* pStaticValue = &staticValue) + { + if (MathF.Round(*pStaticValue) != 1.0f) + { + Console.WriteLine("MathF.Round of an addressed static value failed"); + return Fail; + } + } + + if (MathF.Round(staticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(staticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(staticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 2) failed"); + return Fail; + } + + fixed (float* pStaticValueArray = &staticValueArray[0]) + { + if (MathF.Round(pStaticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(pStaticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(pStaticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Round(program.instanceValue) != 6.0f) + { + Console.WriteLine("MathF.Round of an instance value failed"); + return Fail; + } + + fixed (float* pInstanceValue = &program.instanceValue) + { + if (MathF.Round(*pInstanceValue) != 6.0f) + { + Console.WriteLine("MathF.Round of an addressed instance value failed"); + return Fail; + } + } + + if (MathF.Round(program.instanceValueArray[0]) != 7.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(program.instanceValueArray[1]) != 8.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(program.instanceValueArray[2]) != 9.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 2) failed"); + return Fail; + } + + fixed (float* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (MathF.Round(pInstanceValueArray[0]) != 7.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(pInstanceValueArray[1]) != 8.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(pInstanceValueArray[2]) != 9.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Round(localValue) != 10.0f) + { + Console.WriteLine("MathF.Round of a local value failed"); + return Fail; + } + + float* pLocalValue = &localValue; + + if (MathF.Round(*pLocalValue) != 10.0f) + { + Console.WriteLine("MathF.Round of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathCeilingSingle_r.csproj b/tests/src/JIT/Intrinsics/MathCeilingSingle_r.csproj new file mode 100644 index 0000000..2bd6443 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingSingle_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathCeilingSingle_ro.csproj b/tests/src/JIT/Intrinsics/MathCeilingSingle_ro.csproj new file mode 100644 index 0000000..5ccf9a3 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathCeilingSingle_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathFloorDouble.cs b/tests/src/JIT/Intrinsics/MathFloorDouble.cs new file mode 100644 index 0000000..1835ade --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorDouble.cs @@ -0,0 +1,172 @@ +// 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 MathFloorDoubleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const double constantValue = 0.0; + + public static double staticValue = 1.1; + + public static double[] staticValueArray = new double[] + { + 2.2, + 3.3, + 4.4 + }; + + public double instanceValue = 5.5; + + public double[] instanceValueArray = new double[] + { + 6.6, + 7.7, + 8.8 + }; + + unsafe static int Main(string[] args) + { + double localValue = 9.9; + + var program = new Program(); + + if (Math.Floor(constantValue) != 0.0) + { + Console.WriteLine("Math.Floor of a constant value failed"); + return Fail; + } + + if (Math.Floor(staticValue) != 1.0) + { + Console.WriteLine("Math.Floor of a static value failed"); + return Fail; + } + + fixed (double* pStaticValue = &staticValue) + { + if (Math.Floor(*pStaticValue) != 1.0) + { + Console.WriteLine("Math.Floor of an addressed static value failed"); + return Fail; + } + } + + if (Math.Floor(staticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Floor of a static value array (index 0) failed"); + return Fail; + } + + if (Math.Floor(staticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Floor of a static value array (index 1) failed"); + return Fail; + } + + if (Math.Floor(staticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Floor of a static value array (index 2) failed"); + return Fail; + } + + fixed (double* pStaticValueArray = &staticValueArray[0]) + { + if (Math.Floor(pStaticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Floor of a addressed static value array (index 0) failed"); + return Fail; + } + + if (Math.Floor(pStaticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Floor of a addressed static value array (index 1) failed"); + return Fail; + } + + if (Math.Floor(pStaticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Floor of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (Math.Floor(program.instanceValue) != 5.0) + { + Console.WriteLine("Math.Floor of an instance value failed"); + return Fail; + } + + fixed (double* pInstanceValue = &program.instanceValue) + { + if (Math.Floor(*pInstanceValue) != 5.0) + { + Console.WriteLine("Math.Floor of an addressed instance value failed"); + return Fail; + } + } + + if (Math.Floor(program.instanceValueArray[0]) != 6.0) + { + Console.WriteLine("Math.Floor of an instance value array (index 0) failed"); + return Fail; + } + + if (Math.Floor(program.instanceValueArray[1]) != 7.0) + { + Console.WriteLine("Math.Floor of an instance value array (index 1) failed"); + return Fail; + } + + if (Math.Floor(program.instanceValueArray[2]) != 8.0) + { + Console.WriteLine("Math.Floor of an instance value array (index 2) failed"); + return Fail; + } + + fixed (double* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (Math.Floor(pInstanceValueArray[0]) != 6.0) + { + Console.WriteLine("Math.Floor of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (Math.Floor(pInstanceValueArray[1]) != 7.0) + { + Console.WriteLine("Math.Floor of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (Math.Floor(pInstanceValueArray[2]) != 8.0) + { + Console.WriteLine("Math.Floor of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (Math.Floor(localValue) != 9.0) + { + Console.WriteLine("Math.Floor of a local value failed"); + return Fail; + } + + double* pLocalValue = &localValue; + + if (Math.Floor(*pLocalValue) != 9.0) + { + Console.WriteLine("Math.Floor of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathFloorDouble_r.csproj b/tests/src/JIT/Intrinsics/MathFloorDouble_r.csproj new file mode 100644 index 0000000..3f6bd4d --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorDouble_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathFloorDouble_ro.csproj b/tests/src/JIT/Intrinsics/MathFloorDouble_ro.csproj new file mode 100644 index 0000000..c1830a1 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorDouble_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathFloorSingle.cs b/tests/src/JIT/Intrinsics/MathFloorSingle.cs new file mode 100644 index 0000000..5a312fb --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorSingle.cs @@ -0,0 +1,172 @@ +// 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 MathFloorSingleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const float constantValue = 0.0f; + + public static float staticValue = 1.1f; + + public static float[] staticValueArray = new float[] + { + 2.2f, + 3.3f, + 4.4f + }; + + public float instanceValue = 5.5f; + + public float[] instanceValueArray = new float[] + { + 6.6f, + 7.7f, + 8.8f + }; + + unsafe static int Main(string[] args) + { + float localValue = 9.9f; + + var program = new Program(); + + if (MathF.Floor(constantValue) != 0.0f) + { + Console.WriteLine("MathF.Floor of a constant value failed"); + return Fail; + } + + if (MathF.Floor(staticValue) != 1.0f) + { + Console.WriteLine("MathF.Floor of a static value failed"); + return Fail; + } + + fixed (float* pStaticValue = &staticValue) + { + if (MathF.Floor(*pStaticValue) != 1.0f) + { + Console.WriteLine("MathF.Floor of an addressed static value failed"); + return Fail; + } + } + + if (MathF.Floor(staticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Floor of a static value array (index 0) failed"); + return Fail; + } + + if (MathF.Floor(staticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Floor of a static value array (index 1) failed"); + return Fail; + } + + if (MathF.Floor(staticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Floor of a static value array (index 2) failed"); + return Fail; + } + + fixed (float* pStaticValueArray = &staticValueArray[0]) + { + if (MathF.Floor(pStaticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Floor of a addressed static value array (index 0) failed"); + return Fail; + } + + if (MathF.Floor(pStaticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Floor of a addressed static value array (index 1) failed"); + return Fail; + } + + if (MathF.Floor(pStaticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Floor of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Floor(program.instanceValue) != 5.0f) + { + Console.WriteLine("MathF.Floor of an instance value failed"); + return Fail; + } + + fixed (float* pInstanceValue = &program.instanceValue) + { + if (MathF.Floor(*pInstanceValue) != 5.0f) + { + Console.WriteLine("MathF.Floor of an addressed instance value failed"); + return Fail; + } + } + + if (MathF.Floor(program.instanceValueArray[0]) != 6.0f) + { + Console.WriteLine("MathF.Floor of an instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Floor(program.instanceValueArray[1]) != 7.0f) + { + Console.WriteLine("MathF.Floor of an instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Floor(program.instanceValueArray[2]) != 8.0f) + { + Console.WriteLine("MathF.Floor of an instance value array (index 2) failed"); + return Fail; + } + + fixed (float* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (MathF.Floor(pInstanceValueArray[0]) != 6.0f) + { + Console.WriteLine("MathF.Floor of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Floor(pInstanceValueArray[1]) != 7.0f) + { + Console.WriteLine("MathF.Floor of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Floor(pInstanceValueArray[2]) != 8.0f) + { + Console.WriteLine("MathF.Floor of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Floor(localValue) != 9.0f) + { + Console.WriteLine("MathF.Floor of a local value failed"); + return Fail; + } + + float* pLocalValue = &localValue; + + if (MathF.Floor(*pLocalValue) != 9.0f) + { + Console.WriteLine("MathF.Floor of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathFloorSingle_r.csproj b/tests/src/JIT/Intrinsics/MathFloorSingle_r.csproj new file mode 100644 index 0000000..bf0b95a --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorSingle_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathFloorSingle_ro.csproj b/tests/src/JIT/Intrinsics/MathFloorSingle_ro.csproj new file mode 100644 index 0000000..3a3d3e0 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathFloorSingle_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathRoundDouble.cs b/tests/src/JIT/Intrinsics/MathRoundDouble.cs new file mode 100644 index 0000000..f81afaf --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundDouble.cs @@ -0,0 +1,172 @@ +// 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 MathRoundDoubleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const double constantValue = 0.0; + + public static double staticValue = 1.1; + + public static double[] staticValueArray = new double[] + { + 2.2, + 3.3, + 4.4 + }; + + public double instanceValue = 5.5; + + public double[] instanceValueArray = new double[] + { + 6.6, + 7.7, + 8.8 + }; + + unsafe static int Main(string[] args) + { + double localValue = 9.9; + + var program = new Program(); + + if (Math.Round(constantValue) != 0.0) + { + Console.WriteLine("Math.Round of a constant value failed"); + return Fail; + } + + if (Math.Round(staticValue) != 1.0) + { + Console.WriteLine("Math.Round of a static value failed"); + return Fail; + } + + fixed (double* pStaticValue = &staticValue) + { + if (Math.Round(*pStaticValue) != 1.0) + { + Console.WriteLine("Math.Round of an addressed static value failed"); + return Fail; + } + } + + if (Math.Round(staticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Round of a static value array (index 0) failed"); + return Fail; + } + + if (Math.Round(staticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Round of a static value array (index 1) failed"); + return Fail; + } + + if (Math.Round(staticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Round of a static value array (index 2) failed"); + return Fail; + } + + fixed (double* pStaticValueArray = &staticValueArray[0]) + { + if (Math.Round(pStaticValueArray[0]) != 2.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 0) failed"); + return Fail; + } + + if (Math.Round(pStaticValueArray[1]) != 3.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 1) failed"); + return Fail; + } + + if (Math.Round(pStaticValueArray[2]) != 4.0) + { + Console.WriteLine("Math.Round of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (Math.Round(program.instanceValue) != 6.0) + { + Console.WriteLine("Math.Round of an instance value failed"); + return Fail; + } + + fixed (double* pInstanceValue = &program.instanceValue) + { + if (Math.Round(*pInstanceValue) != 6.0) + { + Console.WriteLine("Math.Round of an addressed instance value failed"); + return Fail; + } + } + + if (Math.Round(program.instanceValueArray[0]) != 7.0) + { + Console.WriteLine("Math.Round of an instance value array (index 0) failed"); + return Fail; + } + + if (Math.Round(program.instanceValueArray[1]) != 8.0) + { + Console.WriteLine("Math.Round of an instance value array (index 1) failed"); + return Fail; + } + + if (Math.Round(program.instanceValueArray[2]) != 9.0) + { + Console.WriteLine("Math.Round of an instance value array (index 2) failed"); + return Fail; + } + + fixed (double* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (Math.Round(pInstanceValueArray[0]) != 7.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (Math.Round(pInstanceValueArray[1]) != 8.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (Math.Round(pInstanceValueArray[2]) != 9.0) + { + Console.WriteLine("Math.Round of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (Math.Round(localValue) != 10.0) + { + Console.WriteLine("Math.Round of a local value failed"); + return Fail; + } + + double* pLocalValue = &localValue; + + if (Math.Round(*pLocalValue) != 10.0) + { + Console.WriteLine("Math.Round of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathRoundDouble_r.csproj b/tests/src/JIT/Intrinsics/MathRoundDouble_r.csproj new file mode 100644 index 0000000..056ef70 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundDouble_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathRoundDouble_ro.csproj b/tests/src/JIT/Intrinsics/MathRoundDouble_ro.csproj new file mode 100644 index 0000000..e6f6a6f --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundDouble_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathRoundSingle.cs b/tests/src/JIT/Intrinsics/MathRoundSingle.cs new file mode 100644 index 0000000..aa6ca50 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundSingle.cs @@ -0,0 +1,172 @@ +// 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 MathRoundSingleTest +{ + class Program + { + public const int Pass = 100; + public const int Fail = 0; + + public const float constantValue = 0.0f; + + public static float staticValue = 1.1f; + + public static float[] staticValueArray = new float[] + { + 2.2f, + 3.3f, + 4.4f + }; + + public float instanceValue = 5.5f; + + public float[] instanceValueArray = new float[] + { + 6.6f, + 7.7f, + 8.8f + }; + + unsafe static int Main(string[] args) + { + float localValue = 9.9f; + + var program = new Program(); + + if (MathF.Round(constantValue) != 0.0f) + { + Console.WriteLine("MathF.Round of a constant value failed"); + return Fail; + } + + if (MathF.Round(staticValue) != 1.0f) + { + Console.WriteLine("MathF.Round of a static value failed"); + return Fail; + } + + fixed (float* pStaticValue = &staticValue) + { + if (MathF.Round(*pStaticValue) != 1.0f) + { + Console.WriteLine("MathF.Round of an addressed static value failed"); + return Fail; + } + } + + if (MathF.Round(staticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(staticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(staticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Round of a static value array (index 2) failed"); + return Fail; + } + + fixed (float* pStaticValueArray = &staticValueArray[0]) + { + if (MathF.Round(pStaticValueArray[0]) != 2.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(pStaticValueArray[1]) != 3.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(pStaticValueArray[2]) != 4.0f) + { + Console.WriteLine("MathF.Round of a addressed static value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Round(program.instanceValue) != 6.0f) + { + Console.WriteLine("MathF.Round of an instance value failed"); + return Fail; + } + + fixed (float* pInstanceValue = &program.instanceValue) + { + if (MathF.Round(*pInstanceValue) != 6.0f) + { + Console.WriteLine("MathF.Round of an addressed instance value failed"); + return Fail; + } + } + + if (MathF.Round(program.instanceValueArray[0]) != 7.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(program.instanceValueArray[1]) != 8.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(program.instanceValueArray[2]) != 9.0f) + { + Console.WriteLine("MathF.Round of an instance value array (index 2) failed"); + return Fail; + } + + fixed (float* pInstanceValueArray = &program.instanceValueArray[0]) + { + if (MathF.Round(pInstanceValueArray[0]) != 7.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 0) failed"); + return Fail; + } + + if (MathF.Round(pInstanceValueArray[1]) != 8.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 1) failed"); + return Fail; + } + + if (MathF.Round(pInstanceValueArray[2]) != 9.0f) + { + Console.WriteLine("MathF.Round of a addressed instance value array (index 2) failed"); + return Fail; + } + } + + if (MathF.Round(localValue) != 10.0f) + { + Console.WriteLine("MathF.Round of a local value failed"); + return Fail; + } + + float* pLocalValue = &localValue; + + if (MathF.Round(*pLocalValue) != 10.0f) + { + Console.WriteLine("MathF.Round of an addressed local value failed"); + return Fail; + } + + return Pass; + } + } +} diff --git a/tests/src/JIT/Intrinsics/MathRoundSingle_r.csproj b/tests/src/JIT/Intrinsics/MathRoundSingle_r.csproj new file mode 100644 index 0000000..fa1845c --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundSingle_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + + + + + + + + + + + diff --git a/tests/src/JIT/Intrinsics/MathRoundSingle_ro.csproj b/tests/src/JIT/Intrinsics/MathRoundSingle_ro.csproj new file mode 100644 index 0000000..d8db5f6 --- /dev/null +++ b/tests/src/JIT/Intrinsics/MathRoundSingle_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + true + None + True + + + + + + + + + + -- 2.7.4