Disable FinancialTests on ARM (dotnet/corefx#39391)
authorCharles Stoner <chucks@microsoft.com>
Fri, 12 Jul 2019 20:18:16 +0000 (13:18 -0700)
committerGitHub <noreply@github.com>
Fri, 12 Jul 2019 20:18:16 +0000 (13:18 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/137f24a5acdee6bb9b3d57b5d39c83d20df2d42d

src/libraries/Microsoft.VisualBasic.Core/tests/FinancialTests.cs

index 64ebf96..6a9164d 100644 (file)
@@ -3,13 +3,14 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
-using System.Collections.Generic;
 using Xunit;
 
 namespace Microsoft.VisualBasic.Tests
 {
     public class FinancialTests
     {
+        private static bool IsNotArmOrAlpine() => !PlatformDetection.IsArmOrArm64Process && !PlatformDetection.IsAlpine;
+
         /// <summary>
         /// The accuracy of some numeric parsing and formatting has been increased,
         /// so this will use correct value if the tests run on Full Framework.
@@ -20,7 +21,7 @@ namespace Microsoft.VisualBasic.Tests
             Assert.Equal(expected, actual);
         }
 
-        [Theory]
+        [ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
         [InlineData(0, 1.0, 1.0, 1.0, 1.0, 0, 0)]
         [InlineData(2000.0, 500.0, 2.0, 1.0, 2.0, 1500.0, 1500.0)]
         [InlineData(10000.0, 4350.0, 84.0, 35.0, 2.0, 57.3268063538875, 57.32680635388748)]
@@ -30,11 +31,6 @@ namespace Microsoft.VisualBasic.Tests
         [InlineData(10100.0, 10100.0, 70.0, 20.0, 2.0, 0, 0)] // cost = salvage
         public void DDB(double Cost, double Salvage, double Life, double Period, double Factor, double expectedOld, double expectedNew)
         {
-            if (PlatformDetection.IsAlpine)
-            {
-                // some tests fail due to precision
-                return;
-            }
             AreEqual(expectedOld, expectedNew, Financial.DDB(Cost, Salvage, Life, Period, Factor));
         }
 
@@ -73,7 +69,7 @@ namespace Microsoft.VisualBasic.Tests
             AreEqual(-4182.65729113816, -4182.657291138164, Financial.FV(0.0083, 15, 263.0));
         }
 
-        [Theory]
+        [ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
         [InlineData(0, 1.0, 1.0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
         [InlineData(0.1 / 12, 12.0, 48.0, -20000.0, 0, DueDate.BegOfPeriod, 133.00409235109, 133.00409235108953)]
         [InlineData(0.008, 4, 12, 3000, 0, 0, -18.2133959841799, -18.21339598417987)]
@@ -84,11 +80,6 @@ namespace Microsoft.VisualBasic.Tests
         [InlineData(0.008, 4, 12, 3000, 0, 7, -18.0688452224006, -18.068845222400633)] // type <> 0 and type <> 1
         public void IPmt(double Rate, double Per, double NPer, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
         {
-            if (PlatformDetection.IsAlpine)
-            {
-                // some tests fail due to precision
-                return;
-            }
             AreEqual(expectedOld, expectedNew, Financial.IPmt(Rate, Per, NPer, PV, FV, Due));
         }
 
@@ -217,7 +208,7 @@ namespace Microsoft.VisualBasic.Tests
             AreEqual(131.224540233228, 131.2245402332282, Financial.Pmt(0.007, 25, -3000));
         }
 
-        [Theory]
+        [ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
         [InlineData(0, 1.0, 1.0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
         [InlineData(0.02 / 12, 1.0, 24, -10000, 0, DueDate.BegOfPeriod, 424.694809003121, 424.6948090031214)]
         [InlineData(0.008, 4, 12, 3000, 0, DueDate.EndOfPeriod, -244.976482926292, -244.97648292629228)]
@@ -227,11 +218,6 @@ namespace Microsoft.VisualBasic.Tests
         [InlineData(0.008, 4, 12, 3000, 0, 7, -243.03222512529, -243.03222512529004)] // type <> 0 and type <> 1
         public void PPmt(double Rate, double Per, double NPer, double PV, double FV, DueDate Due, double expectedOld, double expectedNew)
         {
-            if (PlatformDetection.IsAlpine)
-            {
-                // some tests fail due to precision
-                return;
-            }
             AreEqual(expectedOld, expectedNew, Financial.PPmt(Rate, Per, NPer, PV, FV, Due));
         }
 
@@ -242,7 +228,7 @@ namespace Microsoft.VisualBasic.Tests
             AreEqual(-244.976482926292, -244.97648292629228, Financial.PPmt(0.008, 4, 12, 3000));
         }
 
-        [Theory]
+        [ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
         [InlineData(0, 0, 0, 0, DueDate.EndOfPeriod, 0, 0)]
         [InlineData(0.02 / 12, 12.0, -100.0, -100.0, DueDate.BegOfPeriod, 1287.10048252122, 1287.1004825212165)]
         [InlineData(0.008, 31, 2000.0, 0, DueDate.EndOfPeriod, -54717.4159104136, -54717.41591041358)]
@@ -254,11 +240,6 @@ namespace Microsoft.VisualBasic.Tests
         [InlineData(1E25, 12, 1797, 0, DueDate.BegOfPeriod, -1797, -1797)] // overflow
         public void PV(double Rate, double NPer, double Pmt, double FV, DueDate Due, double expectedOld, double expectedNew)
         {
-            if (PlatformDetection.IsAlpine)
-            {
-                // some tests fail due to precision
-                return;
-            }
             AreEqual(expectedOld, expectedNew, Financial.PV(Rate, NPer, Pmt, FV, Due));
         }
 
@@ -269,7 +250,7 @@ namespace Microsoft.VisualBasic.Tests
             AreEqual(-2952.94485232014, -2952.944852320145, Financial.PV(0.008, 4, 12, 3000));
         }
 
-        [Theory]
+        [ConditionalTheory(nameof(IsNotArmOrAlpine))] // some tests fail due to precision
         [InlineData(1.0, 1.0, 1.0, 0, DueDate.EndOfPeriod, 0, -2, -2)]
         [InlineData(24.0, -800.0, 10000.0, 0.0, DueDate.BegOfPeriod, 0.1, 0.0676702786565114, 0.06767027865651142)]
         [InlineData(12, -263.0, 3000, 0, DueDate.EndOfPeriod, 0.1, 0.00788643837763396, 0.007886438377633958)]
@@ -278,11 +259,6 @@ namespace Microsoft.VisualBasic.Tests
         [InlineData(12, -3000.0, 300, 0, DueDate.EndOfPeriod, 0.1, -1.98502387722876, -1.9850238772287565)] // pmt > pv
         public void Rate(double NPer, double Pmt, double PV, double FV, DueDate Due, double Guess, double expectedOld, double expectedNew)
         {
-            if (PlatformDetection.IsAlpine)
-            {
-                // some tests fail due to precision
-                return;
-            }
             AreEqual(expectedOld, expectedNew, Financial.Rate(NPer, Pmt, PV, FV, Due, Guess));
         }
 
@@ -337,6 +313,5 @@ namespace Microsoft.VisualBasic.Tests
         {
             Assert.Throws<ArgumentException>(() => Financial.SYD(Cost, Salvage, Life, Period));
         }
-
     }
 }