Use Optional::hasValue() instead of Optional::has_value()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 00:40:09 +0000 (00:40 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 00:40:09 +0000 (00:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192948

Reviewed by Tim Horton.

Source/JavaScriptCore:

* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):

Source/WebCore:

* bindings/js/DOMPromiseProxy.h:
(WebCore::DOMPromiseProxy<IDLType>::isFulfilled const):
(WebCore::DOMPromiseProxy<IDLVoid>::isFulfilled const):
(WebCore::DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled const):
* dom/DataTransferItemList.h:
(WebCore::DataTransferItemList::hasItems const):
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::captionDisplayMode):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::wouldTaintOrigin const):
* platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected):
* platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
(webKitMediaSrcUpdatePresentationSize):
* platform/mac/NSScrollerImpDetails.mm:
(WebCore::ScrollerStyle::recommendedScrollerStyle):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::setExplicitValue):

Source/WebKit:

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::AutomationCommandError::toProtocolString):
(WebKit::WebAutomationSession::willClosePage):
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout):

Source/WTF:

* wtf/Hasher.h:
(WTF::add):
* wtf/Optional.h:

Tools:

* TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/FileSystem.cpp:
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239477 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py
Source/WTF/ChangeLog
Source/WTF/wtf/Hasher.h
Source/WTF/wtf/Optional.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/DOMPromiseProxy.h
Source/WebCore/dom/DataTransferItemList.h
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp
Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp
Source/WebCore/platform/mac/NSScrollerImpDetails.mm
Source/WebCore/rendering/RenderListItem.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp
Tools/TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp
Tools/TestWebKitAPI/Tests/WebCore/FileSystem.cpp

index 2e7c3ea..5f11670 100644 (file)
@@ -1,3 +1,14 @@
+2018-12-20  Chris Dumez  <cdumez@apple.com>
+
+        Use Optional::hasValue() instead of Optional::has_value()
+        https://bugs.webkit.org/show_bug.cgi?id=192948
+
+        Reviewed by Tim Horton.
+
+        * inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
+        (CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
+        (CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
+
 2018-12-20  Keith Miller  <keith_miller@apple.com>
 
         Add support for globalThis
index e20aaf3..a15961a 100755 (executable)
@@ -169,7 +169,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator):
 
             if parameter.is_optional:
                 if CppGenerator.should_use_wrapper_for_return_type(parameter.type):
-                    out_parameter_assignments.append('    if (%(parameterName)s.has_value())' % param_args)
+                    out_parameter_assignments.append('    if (%(parameterName)s.hasValue())' % param_args)
                     out_parameter_assignments.append('        jsonMessage->%(keyedSetMethod)s("%(parameterKey)s"_s, *%(parameterName)s);' % param_args)
                 else:
                     out_parameter_assignments.append('    if (%(parameterName)s)' % param_args)
@@ -264,7 +264,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator):
                 out_parameter_declarations.append('    %(parameterType)s out_%(parameterName)s;' % param_args)
                 if parameter.is_optional:
                     if CppGenerator.should_use_wrapper_for_return_type(parameter.type):
-                        out_parameter_assignments.append('        if (out_%(parameterName)s.has_value())' % param_args)
+                        out_parameter_assignments.append('        if (out_%(parameterName)s.hasValue())' % param_args)
                         out_parameter_assignments.append('            result->%(keyedSetMethod)s("%(parameterKey)s"_s, *out_%(parameterName)s);' % param_args)
                     else:
                         out_parameter_assignments.append('        if (out_%(parameterName)s)' % param_args)
index 36a3eae..1046e44 100644 (file)
@@ -1,5 +1,16 @@
 2018-12-20  Chris Dumez  <cdumez@apple.com>
 
+        Use Optional::hasValue() instead of Optional::has_value()
+        https://bugs.webkit.org/show_bug.cgi?id=192948
+
+        Reviewed by Tim Horton.
+
+        * wtf/Hasher.h:
+        (WTF::add):
+        * wtf/Optional.h:
+
+2018-12-20  Chris Dumez  <cdumez@apple.com>
+
         Use Optional::valueOr() instead of Optional::value_or()
         https://bugs.webkit.org/show_bug.cgi?id=192933
 
index a3fea4e..7ca3354 100644 (file)
@@ -142,8 +142,8 @@ template<typename T1, typename T2> void add(Hasher& hasher, const std::pair<T1,
 
 template<typename T> void add(Hasher& hasher, const Optional<T>& optional)
 {
-    add(hasher, optional.has_value());
-    if (optional.has_value())
+    add(hasher, optional.hasValue());
+    if (optional.hasValue())
         add(hasher, optional.value());
 }
 
index 6d4e242..bf5a940 100644 (file)
@@ -506,7 +506,6 @@ public:
   // 20.5.4.5, Observers
 
   explicit constexpr operator bool() const __NOEXCEPT { return initialized(); }
-  constexpr bool has_value() const __NOEXCEPT { return initialized(); } // FIXME: Remove this.
   constexpr bool hasValue() const __NOEXCEPT { return initialized(); }
 
   constexpr T const* operator ->() const {
@@ -673,7 +672,7 @@ public:
     return ref != nullptr;
   }
 
-  constexpr bool has_value() const __NOEXCEPT {
+  constexpr bool hasValue() const __NOEXCEPT {
     return ref != nullptr;
   }
 
index 2eee076..3e0e769 100644 (file)
@@ -1,5 +1,35 @@
 2018-12-20  Chris Dumez  <cdumez@apple.com>
 
+        Use Optional::hasValue() instead of Optional::has_value()
+        https://bugs.webkit.org/show_bug.cgi?id=192948
+
+        Reviewed by Tim Horton.
+
+        * bindings/js/DOMPromiseProxy.h:
+        (WebCore::DOMPromiseProxy<IDLType>::isFulfilled const):
+        (WebCore::DOMPromiseProxy<IDLVoid>::isFulfilled const):
+        (WebCore::DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled const):
+        * dom/DataTransferItemList.h:
+        (WebCore::DataTransferItemList::hasItems const):
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::addEventListener):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::captionDisplayMode):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::wouldTaintOrigin const):
+        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
+        (WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected):
+        * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
+        (webKitMediaSrcUpdatePresentationSize):
+        * platform/mac/NSScrollerImpDetails.mm:
+        (WebCore::ScrollerStyle::recommendedScrollerStyle):
+        * rendering/RenderListItem.cpp:
+        (WebCore::RenderListItem::setExplicitValue):
+
+2018-12-20  Chris Dumez  <cdumez@apple.com>
+
         Move HTTPS_UPGRADE code behind a runtime flag, off by default
         https://bugs.webkit.org/show_bug.cgi?id=192937
 
index e75c3ed..48ac3f9 100644 (file)
@@ -145,7 +145,7 @@ inline void DOMPromiseProxy<IDLType>::clear()
 template<typename IDLType>
 inline bool DOMPromiseProxy<IDLType>::isFulfilled() const
 {
-    return m_valueOrException.has_value();
+    return m_valueOrException.hasValue();
 }
 
 template<typename IDLType>
@@ -213,7 +213,7 @@ inline void DOMPromiseProxy<IDLVoid>::clear()
 
 inline bool DOMPromiseProxy<IDLVoid>::isFulfilled() const
 {
-    return m_valueOrException.has_value();
+    return m_valueOrException.hasValue();
 }
 
 inline void DOMPromiseProxy<IDLVoid>::resolve()
@@ -282,7 +282,7 @@ inline void DOMPromiseProxyWithResolveCallback<IDLType>::clear()
 template<typename IDLType>
 inline bool DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled() const
 {
-    return m_valueOrException.has_value();
+    return m_valueOrException.hasValue();
 }
 
 template<typename IDLType>
index 9a55b23..b2413b8 100644 (file)
@@ -65,7 +65,7 @@ public:
 
     void didClearStringData(const String& type);
     void didSetStringData(const String& type);
-    bool hasItems() const { return m_items.has_value(); }
+    bool hasItems() const { return m_items.hasValue(); }
     const Vector<Ref<DataTransferItem>>& items() const
     {
         ASSERT(m_items);
index d1c87de..c37910e 100644 (file)
@@ -67,7 +67,7 @@ bool EventTarget::addEventListener(const AtomicString& eventType, Ref<EventListe
 {
     auto passive = options.passive;
 
-    if (!passive.has_value() && eventNames().isTouchScrollBlockingEventType(eventType)) {
+    if (!passive.hasValue() && eventNames().isTouchScrollBlockingEventType(eventType)) {
         if (is<DOMWindow>(*this)) {
             auto& window = downcast<DOMWindow>(*this);
             if (auto* document = window.document())
index 35429f1..3442eda 100644 (file)
@@ -6583,7 +6583,7 @@ void HTMLMediaElement::captionPreferencesChanged()
 
 CaptionUserPreferences::CaptionDisplayMode HTMLMediaElement::captionDisplayMode()
 {
-    if (!m_captionDisplayMode.has_value()) {
+    if (!m_captionDisplayMode.hasValue()) {
         if (document().page())
             m_captionDisplayMode = document().page()->group().captionPreferences().captionDisplayMode();
         else
index 6551c11..f1e5610 100644 (file)
@@ -1061,7 +1061,7 @@ bool MediaPlayer::didPassCORSAccessCheck() const
 bool MediaPlayer::wouldTaintOrigin(const SecurityOrigin& origin) const
 {
     auto wouldTaint = m_private->wouldTaintOrigin(origin);
-    if (wouldTaint.has_value())
+    if (wouldTaint.hasValue())
         return wouldTaint.value();
 
     if (m_url.protocolIsData())
index 9fbe7bf..d67ef25 100644 (file)
@@ -383,7 +383,7 @@ void AppendPipeline::parseDemuxerSrcPadCaps(GstCaps* demuxerSrcPadCaps)
             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Invalid;
     } else if (doCapsHaveType(m_demuxerSrcPadCaps.get(), GST_VIDEO_CAPS_TYPE_PREFIX)) {
         Optional<FloatSize> size = getVideoResolutionFromCaps(m_demuxerSrcPadCaps.get());
-        if (size.has_value())
+        if (size.hasValue())
             m_presentationSize = size.value();
         else
             m_presentationSize = WebCore::FloatSize();
index 8ea8961..6bfe48a 100644 (file)
@@ -721,7 +721,7 @@ void MediaPlayerPrivateGStreamerMSE::trackDetected(RefPtr<AppendPipeline> append
 
     if (doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
         Optional<FloatSize> size = getVideoResolutionFromCaps(caps);
-        if (size.has_value())
+        if (size.hasValue())
             m_videoSize = size.value();
     }
 
index 3f50d76..1ad4424 100644 (file)
@@ -459,7 +459,7 @@ void webKitMediaSrcUpdatePresentationSize(GstCaps* caps, Stream* stream)
     GST_OBJECT_LOCK(stream->parent);
     if (WebCore::doCapsHaveType(caps, GST_VIDEO_CAPS_TYPE_PREFIX)) {
         Optional<WebCore::FloatSize> size = WebCore::getVideoResolutionFromCaps(caps);
-        if (size.has_value())
+        if (size.hasValue())
             stream->presentationSize = size.value();
         else
             stream->presentationSize = WebCore::FloatSize();
index bfe3ae2..dad045f 100644 (file)
@@ -38,7 +38,7 @@ Optional<bool> ScrollerStyle::m_useOverlayScrollbars;
 
 NSScrollerStyle ScrollerStyle::recommendedScrollerStyle()
 {
-    if (m_useOverlayScrollbars.has_value())
+    if (m_useOverlayScrollbars.hasValue())
         return *m_useOverlayScrollbars ? NSScrollerStyleOverlay : NSScrollerStyleLegacy;
     
     if (DeprecatedGlobalSettings::usesOverlayScrollbars())
index e4837e1..d923eea 100644 (file)
@@ -407,7 +407,7 @@ void RenderListItem::setExplicitValue(Optional<int> value)
         if (m_valueWasSetExplicitly && m_value == value)
             return;
     }
-    m_valueWasSetExplicitly = value.has_value();
+    m_valueWasSetExplicitly = value.hasValue();
     m_value = value;
     explicitValueChanged();
 }
index f90802d..127c013 100644 (file)
@@ -1,3 +1,16 @@
+2018-12-20  Chris Dumez  <cdumez@apple.com>
+
+        Use Optional::hasValue() instead of Optional::has_value()
+        https://bugs.webkit.org/show_bug.cgi?id=192948
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::AutomationCommandError::toProtocolString):
+        (WebKit::WebAutomationSession::willClosePage):
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout):
+
 2018-12-20  Jeremy Jones  <jeremyj@apple.com>
 
         Flicker when exiting element fullscreen.
index 57df5f3..ba527d2 100644 (file)
@@ -58,7 +58,7 @@ namespace WebKit {
 String AutomationCommandError::toProtocolString()
 {
     String protocolErrorName = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(type);
-    if (!message.has_value())
+    if (!message.hasValue())
         return protocolErrorName;
 
     return makeString(protocolErrorName, errorNameAndDetailsSeparator, message.value());
@@ -784,7 +784,7 @@ void WebAutomationSession::willClosePage(const WebPageProxy& page)
 
     // Then tell the input dispatcher to cancel so timers are stopped, and let it go out of scope.
     Optional<Ref<SimulatedInputDispatcher>> inputDispatcher = m_inputDispatchersByPage.take(page.pageID());
-    if (inputDispatcher.has_value())
+    if (inputDispatcher.hasValue())
         inputDispatcher.value()->cancel();
 }
 
index ac5b71b..8edc5e9 100644 (file)
@@ -594,7 +594,7 @@ void WebAutomationSessionProxy::computeElementLayout(uint64_t pageID, uint64_t f
     bool isObscured = false;
     if (containerElement) {
         Optional<WebCore::FloatPoint> frameInViewCenterPoint = elementInViewClientCenterPoint(*containerElement, isObscured);
-        if (frameInViewCenterPoint.has_value()) {
+        if (frameInViewCenterPoint.hasValue()) {
             WebCore::IntPoint rootInViewCenterPoint = mainView->rootViewToContents(frameView->contentsToRootView(WebCore::IntPoint(frameInViewCenterPoint.value())));
             switch (coordinateSystem) {
             case CoordinateSystem::Page:
index 7b1a8b2..e265afd 100644 (file)
@@ -1,5 +1,19 @@
 2018-12-20  Chris Dumez  <cdumez@apple.com>
 
+        Use Optional::hasValue() instead of Optional::has_value()
+        https://bugs.webkit.org/show_bug.cgi?id=192948
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/CBORReaderTest.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2018-12-20  Chris Dumez  <cdumez@apple.com>
+
         Add style script rule to check for uses of std::optional<>
         https://bugs.webkit.org/show_bug.cgi?id=192931
 
index fdeb501..3ab6047 100644 (file)
@@ -64,7 +64,7 @@ TEST(CBORReaderTest, TestReadUint)
 
     for (const UintTestCase& testCase : kUintTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::Unsigned);
         EXPECT_EQ(cbor.value().getInteger(), testCase.value);
     }
@@ -109,7 +109,7 @@ TEST(CBORReaderTest, TestUintEncodedWithNonMinimumByteLength)
     CBORReader::DecoderError errorCode;
     for (const auto& nonMinimalUint : nonMinimalUintEncodings) {
         Optional<CBORValue> cbor = CBORReader::read(nonMinimalUint, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::NonMinimalCBOREncoding);
     }
 }
@@ -135,7 +135,7 @@ TEST(CBORReaderTest, TestReadNegativeInt)
 
     for (const NegativeIntTestCase& testCase : kNegativeIntTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::Negative);
         EXPECT_EQ(cbor.value().getInteger(), testCase.negativeInt);
     }
@@ -155,7 +155,7 @@ TEST(CBORReaderTest, TestReadBytes)
 
     for (const ByteTestCase& testCase : kByteStringTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::ByteString);
         EXPECT_TRUE(cbor.value().getByteString() == testCase.value);
     }
@@ -180,7 +180,7 @@ TEST(CBORReaderTest, TestReadString)
 
     for (const StringTestCase& testCase : kStringTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::String);
         EXPECT_TRUE(cbor.value().getString() == testCase.value);
     }
@@ -208,7 +208,7 @@ TEST(CBORReaderTest, TestReadStringWithNUL)
 
     for (const auto& testCase : kStringTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::String);
         EXPECT_TRUE(cbor.value().getString() == testCase.value);
     }
@@ -225,7 +225,7 @@ TEST(CBORReaderTest, TestReadStringWithInvalidByteSequenceAfterNUL)
     };
     CBORReader::DecoderError errorCode;
     Optional<CBORValue> cbor = CBORReader::read(stringWithInvalidContinuationByte, &errorCode);
-    EXPECT_FALSE(cbor.has_value());
+    EXPECT_FALSE(cbor.hasValue());
     EXPECT_TRUE(errorCode == CBORReader::DecoderError::InvalidUTF8);
 }
 
@@ -239,7 +239,7 @@ TEST(CBORReaderTest, TestReadArray)
     };
 
     Optional<CBORValue> cbor = CBORReader::read(kArrayTestCaseCBOR);
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     const CBORValue cborArray = WTFMove(cbor.value());
     ASSERT_TRUE(cborArray.type() == CBORValue::Type::Array);
     ASSERT_EQ(cborArray.getArray().size(), 25u);
@@ -269,7 +269,7 @@ TEST(CBORReaderTest, TestReadMapWithMapValue)
     };
 
     Optional<CBORValue> cbor = CBORReader::read(kMapTestCaseCBOR);
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     const CBORValue cborVal = WTFMove(cbor.value());
     ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     ASSERT_EQ(cborVal.getMap().size(), 4u);
@@ -313,7 +313,7 @@ TEST(CBORReaderTest, TestReadMapWithIntegerKeys)
     };
 
     Optional<CBORValue> cbor = CBORReader::read(kMapWithIntegerKeyCBOR);
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     const CBORValue cborVal = WTFMove(cbor.value());
     ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     ASSERT_EQ(cborVal.getMap().size(), 4u);
@@ -353,7 +353,7 @@ TEST(CBORReaderTest, TestReadMapWithArray)
     };
 
     Optional<CBORValue> cbor = CBORReader::read(kMapArrayTestCaseCBOR);
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     const CBORValue cborVal = WTFMove(cbor.value());
     ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     ASSERT_EQ(cborVal.getMap().size(), 2u);
@@ -392,7 +392,7 @@ TEST(CBORReaderTest, TestReadNestedMap)
     };
 
     Optional<CBORValue> cbor = CBORReader::read(kNestedMapTestCase);
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     const CBORValue cborVal = WTFMove(cbor.value());
     ASSERT_TRUE(cborVal.type() == CBORValue::Type::Map);
     ASSERT_EQ(cborVal.getMap().size(), 2u);
@@ -429,11 +429,11 @@ TEST(CBORReaderTest, TestIntegerRange)
     };
 
     Optional<CBORValue> maxPositiveInt = CBORReader::read(kMaxPositiveInt);
-    ASSERT_TRUE(maxPositiveInt.has_value());
+    ASSERT_TRUE(maxPositiveInt.hasValue());
     EXPECT_EQ(maxPositiveInt.value().getInteger(), INT64_MAX);
 
     Optional<CBORValue> minNegativeInt = CBORReader::read(kMinNegativeInt);
-    ASSERT_TRUE(minNegativeInt.has_value());
+    ASSERT_TRUE(minNegativeInt.hasValue());
     EXPECT_EQ(minNegativeInt.value().getInteger(), INT64_MIN);
 }
 
@@ -471,7 +471,7 @@ TEST(CBORReaderTest, TestReadSimpleValue)
 
     for (const auto& testCase : kSimpleValueTestCases) {
         Optional<CBORValue> cbor = CBORReader::read(testCase.cborData);
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         ASSERT_TRUE(cbor.value().type() == CBORValue::Type::SimpleValue);
         ASSERT_TRUE(cbor.value().getSimpleValue() == testCase.value);
     }
@@ -491,7 +491,7 @@ TEST(CBORReaderTest, TestReadUnsupportedFloatingPointNumbers)
     for (const auto& unsupported_floating_point : floatingPointCbors) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(unsupported_floating_point, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnsupportedFloatingPointValue);
     }
 }
@@ -517,7 +517,7 @@ TEST(CBORReaderTest, TestIncompleteCBORDataError)
     for (const auto& incomplete_data : incompleteCborList) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(incomplete_data, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::IncompleteCBORData);
     }
 }
@@ -538,7 +538,7 @@ TEST(CBORReaderTest, TestUnsupportedMapKeyFormatError)
 
     CBORReader::DecoderError errorCode;
     Optional<CBORValue> cbor = CBORReader::read(kMapWithUintKey, &errorCode);
-    EXPECT_FALSE(cbor.has_value());
+    EXPECT_FALSE(cbor.hasValue());
     EXPECT_TRUE(errorCode == CBORReader::DecoderError::IncorrectMapKeyType);
 }
 
@@ -567,7 +567,7 @@ TEST(CBORReaderTest, TestUnknownAdditionalInfoError)
     for (const auto& incorrect_cbor : kUnknownAdditionalInfoList) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(incorrect_cbor, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnknownAdditionalInfo);
     }
 }
@@ -590,7 +590,7 @@ TEST(CBORReaderTest, TestTooMuchNestingError)
     for (const auto& zeroDepthData : kZeroDepthCBORList) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(zeroDepthData, &errorCode, 0);
-        EXPECT_TRUE(cbor.has_value());
+        EXPECT_TRUE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
     }
 
@@ -610,11 +610,11 @@ TEST(CBORReaderTest, TestTooMuchNestingError)
 
     CBORReader::DecoderError errorCode;
     Optional<CBORValue> cborSingleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 1);
-    EXPECT_FALSE(cborSingleLayerMax.has_value());
+    EXPECT_FALSE(cborSingleLayerMax.hasValue());
     EXPECT_TRUE(errorCode == CBORReader::DecoderError::TooMuchNesting);
 
     Optional<CBORValue> cborDoubleLayerMax = CBORReader::read(kNestedCBORData, &errorCode, 2);
-    EXPECT_TRUE(cborDoubleLayerMax.has_value());
+    EXPECT_TRUE(cborDoubleLayerMax.hasValue());
     EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
 }
 
@@ -648,7 +648,7 @@ TEST(CBORReaderTest, TestOutOfOrderKeyError)
     for (const auto& unsortedMap : kMapsWithUnsortedKeys) {
         Optional<CBORValue> cbor =
         CBORReader::read(unsortedMap, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::OutOfOrderKey);
     }
 }
@@ -679,7 +679,7 @@ TEST(CBORReaderTest, TestDuplicateKeyError)
     CBORReader::DecoderError errorCode;
 
     Optional<CBORValue> cbor = CBORReader::read(kMapWithDuplicateKey, &errorCode);
-    EXPECT_FALSE(cbor.has_value());
+    EXPECT_FALSE(cbor.hasValue());
     EXPECT_TRUE(errorCode == CBORReader::DecoderError::DuplicateKey);
 }
 
@@ -699,7 +699,7 @@ TEST(CBORReaderTest, TestIncorrectStringEncodingError)
     CBORReader::DecoderError errorCode;
     for (const auto& cbor_byte : utf8CharacterEncodings) {
         Optional<CBORValue> correctlyEncodedCbor = CBORReader::read(cbor_byte, &errorCode);
-        EXPECT_TRUE(correctlyEncodedCbor.has_value());
+        EXPECT_TRUE(correctlyEncodedCbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::CBORNoError);
     }
 
@@ -728,7 +728,7 @@ TEST(CBORReaderTest, TestExtraneousCBORDataError)
     for (const auto& extraneous_cborData : zeroPaddedCborList) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(extraneous_cborData, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::ExtraneousData);
     }
 }
@@ -759,7 +759,7 @@ TEST(CBORReaderTest, TestUnsupportedSimplevalue)
     for (const auto& unsupportedSimpleVal : unsupportedSimpleValues) {
         CBORReader::DecoderError errorCode;
         Optional<CBORValue> cbor = CBORReader::read(unsupportedSimpleVal, &errorCode);
-        EXPECT_FALSE(cbor.has_value());
+        EXPECT_FALSE(cbor.hasValue());
         EXPECT_TRUE(errorCode == CBORReader::DecoderError::UnsupportedSimpleValue);
     }
 }
index 1961a6c..3e9bdd2 100644 (file)
@@ -81,7 +81,7 @@ TEST(CBORWriterTest, TestWriteUint)
 
     for (const UintTestCase& testCase : kUintTestCases) {
         auto cbor = CBORWriter::write(CBORValue(testCase.value));
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
     }
 }
@@ -108,7 +108,7 @@ TEST(CBORWriterTest, TestWriteNegativeInteger)
 
     for (const auto& testCase : kNegativeIntTestCases) {
         auto cbor = CBORWriter::write(CBORValue(testCase.negativeInt));
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
     }
 }
@@ -127,7 +127,7 @@ TEST(CBORWriterTest, TestWriteBytes)
 
     for (const BytesTestCase& testCase : kBytesTestCases) {
         auto cbor = CBORWriter::write(CBORValue(testCase.bytes));
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
     }
 }
@@ -151,7 +151,7 @@ TEST(CBORWriterTest, TestWriteString)
 
     for (const StringTestCase& testCase : kStringTestCases) {
         auto cbor = CBORWriter::write(CBORValue(testCase.string));
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
     }
 }
@@ -168,7 +168,7 @@ TEST(CBORWriterTest, TestWriteArray)
     for (int64_t i = 1; i <= 25; i++)
         array.append(CBORValue(i));
     auto cbor = CBORWriter::write(CBORValue(array));
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     EXPECT_TRUE(eq(cbor.value(), kArrayTestCaseCbor, sizeof(kArrayTestCaseCbor)));
 }
 
@@ -278,7 +278,7 @@ TEST(CBORWriterTest, TestWriteMapWithMapValue)
     map[CBORValue(int64_t(4294967296))] = CBORValue("i");
     map[CBORValue(std::numeric_limits<int64_t>::max())] = CBORValue("j");
     auto cbor = CBORWriter::write(CBORValue(map));
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     EXPECT_TRUE(eq(cbor.value(), kMapTestCaseCbor, sizeof(kMapTestCaseCbor)));
 }
 
@@ -301,7 +301,7 @@ TEST(CBORWriterTest, TestWriteMapWithArray)
     array.append(CBORValue(3));
     map[CBORValue("b")] = CBORValue(array);
     auto cbor = CBORWriter::write(CBORValue(map));
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     EXPECT_TRUE(eq(cbor.value(), kMapArrayTestCaseCbor, sizeof(kMapArrayTestCaseCbor)));
 }
 
@@ -327,7 +327,7 @@ TEST(CBORWriterTest, TestWriteNestedMap)
     nestedMap[CBORValue("d")] = CBORValue(3);
     map[CBORValue("b")] = CBORValue(nestedMap);
     auto cbor = CBORWriter::write(CBORValue(map));
-    ASSERT_TRUE(cbor.has_value());
+    ASSERT_TRUE(cbor.hasValue());
     EXPECT_TRUE(eq(cbor.value(), kNestedMapTestCase, sizeof(kNestedMapTestCase)));
 }
 
@@ -345,7 +345,7 @@ TEST(CBORWriterTest, TestWriteSimpleValue)
 
     for (const auto& testCase : kSimpleTestCase) {
         auto cbor = CBORWriter::write(CBORValue(testCase.simpleValue));
-        ASSERT_TRUE(cbor.has_value());
+        ASSERT_TRUE(cbor.hasValue());
         EXPECT_TRUE(eq(cbor.value(), testCase.cbor));
     }
 }
@@ -370,18 +370,18 @@ TEST(CBORWriterTest, TestWriteSingleLayer)
     const CBORValue singleLayerCborMap = CBORValue(simpleMap);
     const CBORValue singleLayerCborArray = CBORValue(simpleArray);
 
-    EXPECT_TRUE(CBORWriter::write(simpleUint, 0).has_value());
-    EXPECT_TRUE(CBORWriter::write(simpleString, 0).has_value());
-    EXPECT_TRUE(CBORWriter::write(simpleBytestring, 0).has_value());
+    EXPECT_TRUE(CBORWriter::write(simpleUint, 0).hasValue());
+    EXPECT_TRUE(CBORWriter::write(simpleString, 0).hasValue());
+    EXPECT_TRUE(CBORWriter::write(simpleBytestring, 0).hasValue());
 
-    EXPECT_TRUE(CBORWriter::write(emptyArrayValue, 0).has_value());
-    EXPECT_TRUE(CBORWriter::write(emptyMapValue, 0).has_value());
+    EXPECT_TRUE(CBORWriter::write(emptyArrayValue, 0).hasValue());
+    EXPECT_TRUE(CBORWriter::write(emptyMapValue, 0).hasValue());
 
-    EXPECT_FALSE(CBORWriter::write(singleLayerCborArray, 0).has_value());
-    EXPECT_TRUE(CBORWriter::write(singleLayerCborArray, 1).has_value());
+    EXPECT_FALSE(CBORWriter::write(singleLayerCborArray, 0).hasValue());
+    EXPECT_TRUE(CBORWriter::write(singleLayerCborArray, 1).hasValue());
 
-    EXPECT_FALSE(CBORWriter::write(singleLayerCborMap, 0).has_value());
-    EXPECT_TRUE(CBORWriter::write(singleLayerCborMap, 1).has_value());
+    EXPECT_FALSE(CBORWriter::write(singleLayerCborMap, 0).hasValue());
+    EXPECT_TRUE(CBORWriter::write(singleLayerCborMap, 1).hasValue());
 }
 
 // Major type 5 nested CBOR map value with following structure.
@@ -396,8 +396,8 @@ TEST(CBORWriterTest, NestedMaps)
     nestedMap[CBORValue("c")] = CBORValue(2);
     nestedMap[CBORValue("d")] = CBORValue(3);
     cborMap[CBORValue("b")] = CBORValue(nestedMap);
-    EXPECT_TRUE(CBORWriter::write(CBORValue(cborMap), 2).has_value());
-    EXPECT_FALSE(CBORWriter::write(CBORValue(cborMap), 1).has_value());
+    EXPECT_TRUE(CBORWriter::write(CBORValue(cborMap), 2).hasValue());
+    EXPECT_FALSE(CBORWriter::write(CBORValue(cborMap), 1).hasValue());
 }
 
 // Testing Write() function for following CBOR structure with depth of 3.
@@ -422,8 +422,8 @@ TEST(CBORWriterTest, UnbalancedNestedContainers)
     cborArray.append(CBORValue(3));
     cborArray.append(CBORValue(cborMap));
 
-    EXPECT_TRUE(CBORWriter::write(CBORValue(cborArray), 3).has_value());
-    EXPECT_FALSE(CBORWriter::write(CBORValue(cborArray), 2).has_value());
+    EXPECT_TRUE(CBORWriter::write(CBORValue(cborArray), 3).hasValue());
+    EXPECT_FALSE(CBORWriter::write(CBORValue(cborArray), 2).hasValue());
 }
 
 // Testing Write() function for following CBOR structure.
@@ -456,8 +456,8 @@ TEST(CBORWriterTest, OverlyNestedCBOR)
     nestedMap[CBORValue("h")] = CBORValue(innerNestedMap);
     map[CBORValue("b")] = CBORValue(nestedMap);
 
-    EXPECT_TRUE(CBORWriter::write(CBORValue(map), 5).has_value());
-    EXPECT_FALSE(CBORWriter::write(CBORValue(map), 4).has_value());
+    EXPECT_TRUE(CBORWriter::write(CBORValue(map), 5).hasValue());
+    EXPECT_FALSE(CBORWriter::write(CBORValue(map), 4).hasValue());
 }
 
 } // namespace TestWebKitAPI
index 483f46d..7662502 100644 (file)
@@ -129,12 +129,12 @@ TEST_F(FileSystemTest, FilesHaveSameVolume)
 TEST_F(FileSystemTest, GetFileMetadataSymlink)
 {
     auto symlinkMetadata = FileSystem::fileMetadata(tempFileSymlinkPath());
-    ASSERT_TRUE(symlinkMetadata.has_value());
+    ASSERT_TRUE(symlinkMetadata.hasValue());
     EXPECT_TRUE(symlinkMetadata.value().type == FileMetadata::Type::SymbolicLink);
     EXPECT_FALSE(static_cast<size_t>(symlinkMetadata.value().length) == strlen(FileSystemTestData));
 
     auto targetMetadata = FileSystem::fileMetadataFollowingSymlinks(tempFileSymlinkPath());
-    ASSERT_TRUE(targetMetadata.has_value());
+    ASSERT_TRUE(targetMetadata.hasValue());
     EXPECT_TRUE(targetMetadata.value().type == FileMetadata::Type::File);
     EXPECT_EQ(strlen(FileSystemTestData), static_cast<size_t>(targetMetadata.value().length));
 }