Skip to content

Commit

Permalink
Adding tests for the new Math APIs (dotnet/corefx#33359)
Browse files Browse the repository at this point in the history
* Updating the System.Runtime.Extensions ref assembly to include the new math functions

* Adding tests to cover the new math functions


Commit migrated from dotnet/corefx@2999b45
  • Loading branch information
tannergooding authored Nov 15, 2018
1 parent 7124cbb commit 8872cba
Show file tree
Hide file tree
Showing 6 changed files with 764 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ public static partial class Math
public static double Atan2(double y, double x) { throw null; }
public static double Atanh(double d) { throw null; }
public static long BigMul(int a, int b) { throw null; }
public static double BitDecrement(double x) { throw null; }
public static double BitIncrement(double x) { throw null; }
public static double Cbrt(double d) { throw null; }
public static decimal Ceiling(decimal d) { throw null; }
public static double Ceiling(double a) { throw null; }
Expand All @@ -798,16 +800,20 @@ public static partial class Math
public static uint Clamp(uint value, uint min, uint max) { throw null; }
[System.CLSCompliantAttribute(false)]
public static ulong Clamp(ulong value, ulong min, ulong max) { throw null; }
public static double CopySign(double x, double y) { throw null; }
public static double Cos(double d) { throw null; }
public static double Cosh(double value) { throw null; }
public static int DivRem(int a, int b, out int result) { throw null; }
public static long DivRem(long a, long b, out long result) { throw null; }
public static double Exp(double d) { throw null; }
public static decimal Floor(decimal d) { throw null; }
public static double Floor(double d) { throw null; }
public static double FusedMultiplyAdd(double x, double y, double z) { throw null; }
public static double IEEERemainder(double x, double y) { throw null; }
public static int ILogB(double x) { throw null; }
public static double Log(double d) { throw null; }
public static double Log(double a, double newBase) { throw null; }
public static double Log2(double x) { throw null; }
public static double Log10(double d) { throw null; }
public static byte Max(byte val1, byte val2) { throw null; }
public static decimal Max(decimal val1, decimal val2) { throw null; }
Expand All @@ -824,6 +830,7 @@ public static partial class Math
public static uint Max(uint val1, uint val2) { throw null; }
[System.CLSCompliantAttribute(false)]
public static ulong Max(ulong val1, ulong val2) { throw null; }
public static double MaxMagnitude(double x, double y) { throw null; }
public static byte Min(byte val1, byte val2) { throw null; }
public static decimal Min(decimal val1, decimal val2) { throw null; }
public static double Min(double val1, double val2) { throw null; }
Expand All @@ -839,6 +846,7 @@ public static partial class Math
public static uint Min(uint val1, uint val2) { throw null; }
[System.CLSCompliantAttribute(false)]
public static ulong Min(ulong val1, ulong val2) { throw null; }
public static double MinMagnitude(double x, double y) { throw null; }
public static double Pow(double x, double y) { throw null; }
public static decimal Round(decimal d) { throw null; }
public static decimal Round(decimal d, int decimals) { throw null; }
Expand All @@ -848,6 +856,7 @@ public static partial class Math
public static double Round(double value, int digits) { throw null; }
public static double Round(double value, int digits, System.MidpointRounding mode) { throw null; }
public static double Round(double value, System.MidpointRounding mode) { throw null; }
public static double ScaleB(double x, int n) { throw null; }
public static int Sign(decimal value) { throw null; }
public static int Sign(double value) { throw null; }
public static int Sign(short value) { throw null; }
Expand All @@ -874,23 +883,32 @@ public static partial class MathF
public static float Atan(float x) { throw null; }
public static float Atanh(float x) { throw null; }
public static float Atan2(float y, float x) { throw null; }
public static float BitDecrement(float x) { throw null; }
public static float BitIncrement(float x) { throw null; }
public static float Cbrt(float x) { throw null; }
public static float Ceiling(float x) { throw null; }
public static float CopySign(float x, float y) { throw null; }
public static float Cos(float x) { throw null; }
public static float Cosh(float x) { throw null; }
public static float Exp(float x) { throw null; }
public static float Floor(float x) { throw null; }
public static float FusedMultiplyAdd(float x, float y, float z) { throw null; }
public static float IEEERemainder(float x, float y) { throw null; }
public static int ILogB(float x) { throw null; }
public static float Log(float x) { throw null; }
public static float Log(float x, float y) { throw null; }
public static float Log2(float x) { throw null; }
public static float Log10(float x) { throw null; }
public static float Max(float x, float y) { throw null; }
public static float MaxMagnitude(float x, float y) { throw null; }
public static float Min(float x, float y) { throw null; }
public static float MinMagnitude(float x, float y) { throw null; }
public static float Pow(float x, float y) { throw null; }
public static float Round(float x) { throw null; }
public static float Round(float x, int digits) { throw null; }
public static float Round(float x, int digits, System.MidpointRounding mode) { throw null; }
public static float Round(float x, System.MidpointRounding mode) { throw null; }
public static float ScaleB(float x, int n) { throw null; }
public static int Sign(float x) { throw null; }
public static float Sin(float x) { throw null; }
public static float Sinh(float x) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Compat issues with assembly System.Runtime.Extensions:
MembersMustExist : Member 'System.Math.FusedMultiplyAdd(System.Double, System.Double, System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.ILogB(System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.Log2(System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.ScaleB(System.Double, System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.FusedMultiplyAdd(System.Single, System.Single, System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.ILogB(System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.Log2(System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.ScaleB(System.Single, System.Int32)' does not exist in the implementation but it does exist in the contract.
Total Issues: 8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Compat issues with assembly System.Runtime.Extensions:
MembersMustExist : Member 'System.Math.FusedMultiplyAdd(System.Double, System.Double, System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.ILogB(System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.Log2(System.Double)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.ScaleB(System.Double, System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.FusedMultiplyAdd(System.Single, System.Single, System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.ILogB(System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.Log2(System.Single)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.MathF.ScaleB(System.Single, System.Int32)' does not exist in the implementation but it does exist in the contract.
Total Issues: 8
10 changes: 9 additions & 1 deletion src/libraries/System.Runtime.Extensions/tests/System/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ public static void Max_Double_NetFramework()
[InlineData(double.NegativeInfinity, double.PositiveInfinity, double.PositiveInfinity)]
[InlineData(double.MinValue, double.MaxValue, double.MaxValue)]
[InlineData(double.NaN, double.NaN, double.NaN)]
[InlineData(-0.0, 0.0, 0.0)]
[InlineData(2.0, -3.0, 2.0)]
[InlineData(3.0, -2.0, 3.0)]
[InlineData(double.PositiveInfinity, double.NaN, double.PositiveInfinity)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
Expand Down Expand Up @@ -1128,6 +1130,8 @@ public static void Max_Single_NetFramework()
[InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity)]
[InlineData(float.MinValue, float.MaxValue, float.MaxValue)]
[InlineData(float.NaN, float.NaN, float.NaN)]
[InlineData(-0.0f, 0.0f, 0.0f)]
[InlineData(2.0f, -3.0f, 2.0f)]
[InlineData(3.0f, -2.0f, 3.0f)]
[InlineData(float.PositiveInfinity, float.NaN, float.PositiveInfinity)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
Expand Down Expand Up @@ -1186,6 +1190,8 @@ public static void Min_Double_NetFramework()
[InlineData(double.NegativeInfinity, double.PositiveInfinity, double.NegativeInfinity)]
[InlineData(double.MinValue, double.MaxValue, double.MinValue)]
[InlineData(double.NaN, double.NaN, double.NaN)]
[InlineData(-0.0, 0.0, -0.0)]
[InlineData(2.0, -3.0, -3.0)]
[InlineData(3.0, -2.0, -2.0)]
[InlineData(double.PositiveInfinity, double.NaN, double.PositiveInfinity)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
Expand Down Expand Up @@ -1237,7 +1243,9 @@ public static void Min_Single_NetFramework()
[InlineData(float.NegativeInfinity, float.PositiveInfinity, float.NegativeInfinity)]
[InlineData(float.MinValue, float.MaxValue, float.MinValue)]
[InlineData(float.NaN, float.NaN, float.NaN)]
[InlineData(3.0, -2.0, -2.0)]
[InlineData(-0.0f, 0.0f, -0.0f)]
[InlineData(2.0f, -3.0f, -3.0f)]
[InlineData(3.0f, -2.0f, -2.0f)]
[InlineData(float.PositiveInfinity, float.NaN, float.PositiveInfinity)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public static void Min_Single_NotNetFramework(float x, float y, float expectedResult)
Expand Down
Loading

0 comments on commit 8872cba

Please sign in to comment.