[tests] Different CPUs have different precision
authorMarek Habersack <grendel@twistedcode.net>
Fri, 12 Jun 2015 15:23:15 +0000 (17:23 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 15 Jul 2015 18:45:21 +0000 (20:45 +0200)
Fix the test to compare the subtraction result to value more
conservative than Double.Epsilon, to account for differences in
different CPU floating point units on Android.

mcs/class/corlib/Test/System/MathTest.cs

index 04e33a90f7ca1ebff835250902a1dc1476a26e22..355b3960b01c10e864abe021e2e19faa9d2d5c77 100644 (file)
@@ -479,13 +479,24 @@ namespace MonoTests.System
                [Test]
                public void TestPow ()
                {
+                       double precision;
                        int iTest = 1;
-
+#if MONODROID
+                       // It fails on Nexus 9 with
+                       //
+                       //   1.3636094460602122 != 1.3636094460602119
+                       //
+                       // when using double_epsilon. Precision differs between different ARM CPUs, so we
+                       // will just use a more conservative value
+                       precision = 0.000001;
+#else
+                       precision = double_epsilon;
+#endif
                        try {
                                double a = Math.Pow (y, x);
                                double b = 1.363609446060212;
 
-                               Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99") + " != " + b.ToString ("G99"));
+                               Assert.IsTrue ((Math.Abs (a - b) <= precision), a.ToString ("G99") + " != " + b.ToString ("G99"));
                                iTest++;
                                Assert.IsTrue (double.IsNaN (Math.Pow (y, double.NaN)));
                                iTest++;