mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 924637 - Document a somewhat counterintuitive case in ExponentComponent, and add test coverage for it. r=waldo
This commit is contained in:
parent
773100dd6a
commit
77a1580baf
@ -139,7 +139,12 @@ IsNegativeZero(double d)
|
||||
return bits == DoubleSignBit;
|
||||
}
|
||||
|
||||
/** Returns the exponent portion of the double. */
|
||||
/**
|
||||
* Returns the exponent portion of the double.
|
||||
*
|
||||
* Zero is not special-cased, so ExponentComponent(0.0) is
|
||||
* -int_fast16_t(DoubleExponentBias).
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE int_fast16_t
|
||||
ExponentComponent(double d)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <math.h>
|
||||
|
||||
using mozilla::DoublesAreIdentical;
|
||||
using mozilla::DoubleExponentBias;
|
||||
using mozilla::ExponentComponent;
|
||||
using mozilla::IsFinite;
|
||||
using mozilla::IsInfinite;
|
||||
using mozilla::IsNaN;
|
||||
@ -102,6 +104,22 @@ TestDoublesAreIdentical()
|
||||
ShouldNotBeIdentical(UnspecifiedNaN(), NegativeInfinity());
|
||||
}
|
||||
|
||||
static void
|
||||
TestExponentComponent()
|
||||
{
|
||||
MOZ_ASSERT(ExponentComponent(0.0) == -int_fast16_t(DoubleExponentBias));
|
||||
MOZ_ASSERT(ExponentComponent(-0.0) == -int_fast16_t(DoubleExponentBias));
|
||||
MOZ_ASSERT(ExponentComponent(0.125) == -3);
|
||||
MOZ_ASSERT(ExponentComponent(0.5) == -1);
|
||||
MOZ_ASSERT(ExponentComponent(1.0) == 0);
|
||||
MOZ_ASSERT(ExponentComponent(1.5) == 0);
|
||||
MOZ_ASSERT(ExponentComponent(2.0) == 1);
|
||||
MOZ_ASSERT(ExponentComponent(7) == 2);
|
||||
MOZ_ASSERT(ExponentComponent(PositiveInfinity()) == DoubleExponentBias + 1);
|
||||
MOZ_ASSERT(ExponentComponent(NegativeInfinity()) == DoubleExponentBias + 1);
|
||||
MOZ_ASSERT(ExponentComponent(UnspecifiedNaN()) == DoubleExponentBias + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
TestPredicates()
|
||||
{
|
||||
@ -152,5 +170,6 @@ int
|
||||
main()
|
||||
{
|
||||
TestDoublesAreIdentical();
|
||||
TestExponentComponent();
|
||||
TestPredicates();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user