static bool TestToMaybe() { BasicValue value(1); BasicValue* nullPointer = nullptr; // Check that a non-null pointer translates into a Some value. Maybe<BasicValue> mayValue = ToMaybe(&value); static_assert(IsSame<Maybe<BasicValue>, DECLTYPE(ToMaybe(&value))>::value, "ToMaybe should return a Maybe<BasicValue>"); MOZ_RELEASE_ASSERT(mayValue.isSome()); MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1); MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasCopyConstructed); MOZ_RELEASE_ASSERT(value.GetStatus() != eWasMovedFrom); // Check that a null pointer translates into a Nothing value. mayValue = ToMaybe(nullPointer); static_assert(IsSame<Maybe<BasicValue>, DECLTYPE(ToMaybe(nullPointer))>::value, "ToMaybe should return a Maybe<BasicValue>"); MOZ_RELEASE_ASSERT(mayValue.isNothing()); return true; }