Bug 910814 - IonMonkey: Add testcases for several FloatingPoint.h predicates. r=waldo
authorDan Gohman <sunfish@google.com>
Mon, 02 Sep 2013 13:53:35 -0700
changeset 145244 8d55e506ea72c75e799ae3d994a6a79a802b3b90
parent 145243 14d93040175bd84f961d2910a2197d03c69cec63
child 145245 2741f512f37b6a085ba18e2c4549fca866febeb5
push id33212
push usersunfish@google.com
push dateMon, 02 Sep 2013 20:58:14 +0000
treeherdermozilla-inbound@8d55e506ea72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs910814
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 910814 - IonMonkey: Add testcases for several FloatingPoint.h predicates. r=waldo
mfbt/tests/TestFloatingPoint.cpp
--- a/mfbt/tests/TestFloatingPoint.cpp
+++ b/mfbt/tests/TestFloatingPoint.cpp
@@ -3,16 +3,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/FloatingPoint.h"
 
 #include <math.h>
 
 using mozilla::DoublesAreIdentical;
+using mozilla::IsFinite;
+using mozilla::IsInfinite;
+using mozilla::IsNaN;
+using mozilla::IsNegative;
+using mozilla::IsNegativeZero;
 using mozilla::NegativeInfinity;
 using mozilla::PositiveInfinity;
 using mozilla::SpecificNaN;
 using mozilla::UnspecifiedNaN;
 
 static void
 ShouldBeIdentical(double d1, double d2)
 {
@@ -92,13 +97,59 @@ TestDoublesAreIdentical()
   ShouldNotBeIdentical(UnspecifiedNaN(), +0.0);
   ShouldNotBeIdentical(UnspecifiedNaN(), -0.0);
   ShouldNotBeIdentical(UnspecifiedNaN(), 1.0);
   ShouldNotBeIdentical(UnspecifiedNaN(), -1.0);
   ShouldNotBeIdentical(UnspecifiedNaN(), PositiveInfinity());
   ShouldNotBeIdentical(UnspecifiedNaN(), NegativeInfinity());
 }
 
+static void
+TestPredicates()
+{
+  MOZ_ASSERT(IsNaN(UnspecifiedNaN()));
+  MOZ_ASSERT(IsNaN(SpecificNaN(1, 17)));;
+  MOZ_ASSERT(IsNaN(SpecificNaN(0, 0xfffffffffff0fULL)));
+  MOZ_ASSERT(!IsNaN(0));
+  MOZ_ASSERT(!IsNaN(-0.0));
+  MOZ_ASSERT(!IsNaN(1.0));
+  MOZ_ASSERT(!IsNaN(PositiveInfinity()));
+  MOZ_ASSERT(!IsNaN(NegativeInfinity()));
+
+  MOZ_ASSERT(IsInfinite(PositiveInfinity()));
+  MOZ_ASSERT(IsInfinite(NegativeInfinity()));
+  MOZ_ASSERT(!IsInfinite(UnspecifiedNaN()));
+  MOZ_ASSERT(!IsInfinite(0));
+  MOZ_ASSERT(!IsInfinite(-0.0));
+  MOZ_ASSERT(!IsInfinite(1.0));
+
+  MOZ_ASSERT(!IsFinite(PositiveInfinity()));
+  MOZ_ASSERT(!IsFinite(NegativeInfinity()));
+  MOZ_ASSERT(!IsFinite(UnspecifiedNaN()));
+  MOZ_ASSERT(IsFinite(0));
+  MOZ_ASSERT(IsFinite(-0.0));
+  MOZ_ASSERT(IsFinite(1.0));
+
+  MOZ_ASSERT(!IsNegative(PositiveInfinity()));
+  MOZ_ASSERT(IsNegative(NegativeInfinity()));
+  MOZ_ASSERT(IsNegative(-0.0));
+  MOZ_ASSERT(!IsNegative(0.0));
+  MOZ_ASSERT(IsNegative(-1.0));
+  MOZ_ASSERT(!IsNegative(1.0));
+
+  MOZ_ASSERT(!IsNegativeZero(PositiveInfinity()));
+  MOZ_ASSERT(!IsNegativeZero(NegativeInfinity()));
+  MOZ_ASSERT(!IsNegativeZero(SpecificNaN(1, 17)));;
+  MOZ_ASSERT(!IsNegativeZero(SpecificNaN(1, 0xfffffffffff0fULL)));
+  MOZ_ASSERT(!IsNegativeZero(SpecificNaN(0, 17)));;
+  MOZ_ASSERT(!IsNegativeZero(SpecificNaN(0, 0xfffffffffff0fULL)));
+  MOZ_ASSERT(IsNegativeZero(-0.0));
+  MOZ_ASSERT(!IsNegativeZero(0.0));
+  MOZ_ASSERT(!IsNegativeZero(-1.0));
+  MOZ_ASSERT(!IsNegativeZero(1.0));
+}
+
 int
 main()
 {
   TestDoublesAreIdentical();
+  TestPredicates();
 }