<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[209542] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/209542">209542</a></dd>
<dt>Author</dt> <dd>keith_miller@apple.com</dd>
<dt>Date</dt> <dd>2016-12-08 09:59:52 -0800 (Thu, 08 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move LEB tests to API tests
https://bugs.webkit.org/show_bug.cgi?id=165586

Reviewed by Saam Barati.

Source/JavaScriptCore:

Delete old stuff.

* testWasm.cpp:
(printUsageStatement):
(CommandLine::parseArguments):
(main):
(runLEBTests): Deleted.

Tools:

Move the tests from testWasm.cpp and make them functions
rather than macros.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/LEBDecoder.cpp: Added.
(TestWebKitAPI::testUnsignedLEBDecode):
(TestWebKitAPI::TEST):
(TestWebKitAPI::testInt32LEBDecode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoretestWasmcpp">trunk/Source/JavaScriptCore/testWasm.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWTFLEBDecodercpp">trunk/Tools/TestWebKitAPI/Tests/WTF/LEBDecoder.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209541 => 209542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-08 17:46:41 UTC (rev 209541)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-08 17:59:52 UTC (rev 209542)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-12-08  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Move LEB tests to API tests
+        https://bugs.webkit.org/show_bug.cgi?id=165586
+
+        Reviewed by Saam Barati.
+
+        Delete old stuff.
+
+        * testWasm.cpp:
+        (printUsageStatement):
+        (CommandLine::parseArguments):
+        (main):
+        (runLEBTests): Deleted.
+
</ins><span class="cx"> 2016-12-07  JF Bastien  &lt;jfbastien@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Cleanup WebAssembly's RETURN_IF_EXCEPTION
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestWasmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/testWasm.cpp (209541 => 209542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/testWasm.cpp        2016-12-08 17:46:41 UTC (rev 209541)
+++ trunk/Source/JavaScriptCore/testWasm.cpp        2016-12-08 17:59:52 UTC (rev 209542)
</span><span class="lines">@@ -46,7 +46,6 @@
</span><span class="cx">         parseArguments(argc, argv);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool m_runLEBTests { false };
</del><span class="cx">     bool m_runWasmTests { false };
</span><span class="cx"> 
</span><span class="cx">     void parseArguments(int, char**);
</span><span class="lines">@@ -56,7 +55,6 @@
</span><span class="cx"> {
</span><span class="cx">     fprintf(stderr, &quot;Usage: testWasm [options]\n&quot;);
</span><span class="cx">     fprintf(stderr, &quot;  -h|--help  Prints this help message\n&quot;);
</span><del>-    fprintf(stderr, &quot;  -l|--leb   Runs the LEB decoder tests\n&quot;);
</del><span class="cx">     fprintf(stderr, &quot;  -w|--web   Run the Wasm tests\n&quot;);
</span><span class="cx">     fprintf(stderr, &quot;\n&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -78,11 +76,6 @@
</span><span class="cx">             RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!strcmp(arg, &quot;-l&quot;) || !strcmp(arg, &quot;--leb&quot;)) {
-            m_runLEBTests = true;
-            continue;
-        }
-
</del><span class="cx">         if (!strcmp(arg, &quot;-w&quot;) || !strcmp(arg, &quot;--web&quot;)) {
</span><span class="cx">             m_runWasmTests = true;
</span><span class="cx">             continue;
</span><span class="lines">@@ -107,109 +100,6 @@
</span><span class="cx"> 
</span><span class="cx"> #define CHECK(x) CHECK_EQ(x, true)
</span><span class="cx"> 
</span><del>-#define FOR_EACH_UNSIGNED_LEB_TEST(macro) \
-    /* Simple tests that use all the bits in the array */ \
-    macro(({ 0x07 }), 0, true, 0x7lu, 1lu) \
-    macro(({ 0x77 }), 0, true, 0x77lu, 1lu) \
-    macro(({ 0x80, 0x07 }), 0, true, 0x380lu, 2lu) \
-    macro(({ 0x89, 0x12 }), 0, true, 0x909lu, 2lu) \
-    macro(({ 0xf3, 0x85, 0x02 }), 0, true, 0x82f3lu, 3lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74 }), 0, true, 0xe9fc2f3lu, 4lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0xf4, 0x7f }), 0, true, 0xfe9fc2f3lu, 5lu) \
-    /* Test with extra trailing numbers */ \
-    macro(({ 0x07, 0x80 }), 0, true, 0x7lu, 1lu) \
-    macro(({ 0x07, 0x75 }), 0, true, 0x7lu, 1lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74, 0x43 }), 0, true, 0xe9fc2f3lu, 4lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74, 0x80 }), 0, true, 0xe9fc2f3lu, 4lu) \
-    /* Test with preceeding numbers */ \
-    macro(({ 0xf3, 0x07 }), 1, true, 0x7lu, 2lu) \
-    macro(({ 0x03, 0x07 }), 1, true, 0x7lu, 2lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77 }), 5, true, 0x77lu, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77 }), 5, true, 0x77lu, 6ul) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02 }), 3, true, 0x82f3lu, 6lu) \
-    /* Test in the middle */ \
-    macro(({ 0xf3, 0x07, 0x89 }), 1, true, 0x7lu, 2lu) \
-    macro(({ 0x03, 0x07, 0x23 }), 1, true, 0x7lu, 2lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77, 0x43 }), 5, true, 0x77lu, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77, 0xf9 }), 5, true, 0x77lu, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02, 0xa4 }), 3, true, 0x82f3lu, 6lu) \
-    /* Test decode too long */ \
-    macro(({ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}), 0, false, 0x0lu, 0lu) \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 1, false, 0x0lu, 0lu) \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 0, false, 0x0lu, 0lu) \
-    /* Test decode off end of array */ \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 2, false, 0x0lu, 0lu) \
-
-
-#define TEST_UNSIGNED_LEB_DECODE(init, startOffset, expectedStatus, expectedResult, expectedOffset) \
-    { \
-        Vector&lt;uint8_t&gt; vector = Vector&lt;uint8_t&gt; init; \
-        size_t offset = startOffset; \
-        uint32_t result; \
-        bool status = WTF::LEBDecoder::decodeUInt32(vector.data(), vector.size(), offset, result); \
-        CHECK_EQ(status, expectedStatus); \
-        if (expectedStatus) { \
-            CHECK_EQ(result, expectedResult); \
-            CHECK_EQ(offset, expectedOffset); \
-        } \
-    };
-
-
-#define FOR_EACH_SIGNED_LEB_TEST(macro) \
-    /* Simple tests that use all the bits in the array */ \
-    macro(({ 0x07 }), 0, true, 0x7, 1lu) \
-    macro(({ 0x77 }), 0, true, -0x9, 1lu) \
-    macro(({ 0x80, 0x07 }), 0, true, 0x380, 2lu) \
-    macro(({ 0x89, 0x12 }), 0, true, 0x909, 2lu) \
-    macro(({ 0xf3, 0x85, 0x02 }), 0, true, 0x82f3, 3lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74 }), 0, true, 0xfe9fc2f3, 4lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0xf4, 0x7f }), 0, true, 0xfe9fc2f3, 5lu) \
-    /* Test with extra trailing numbers */ \
-    macro(({ 0x07, 0x80 }), 0, true, 0x7, 1lu) \
-    macro(({ 0x07, 0x75 }), 0, true, 0x7, 1lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74, 0x43 }), 0, true, 0xfe9fc2f3, 4lu) \
-    macro(({ 0xf3, 0x85, 0xff, 0x74, 0x80 }), 0, true, 0xfe9fc2f3, 4lu) \
-    /* Test with preceeding numbers */ \
-    macro(({ 0xf3, 0x07 }), 1, true, 0x7, 2lu) \
-    macro(({ 0x03, 0x07 }), 1, true, 0x7, 2lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77 }), 5, true, -0x9, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77 }), 5, true, -0x9, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02 }), 3, true, 0x82f3, 6lu) \
-    /* Test in the middle */ \
-    macro(({ 0xf3, 0x07, 0x89 }), 1, true, 0x7, 2lu) \
-    macro(({ 0x03, 0x07, 0x23 }), 1, true, 0x7, 2lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77, 0x43 }), 5, true, -0x9, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77, 0xf9 }), 5, true, -0x9, 6lu) \
-    macro(({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02, 0xa4 }), 3, true, 0x82f3, 6lu) \
-    /* Test decode too long */ \
-    macro(({ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}), 0, false, 0x0, 0lu) \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 1, false, 0x0, 0lu) \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 0, false, 0x0, 0lu) \
-    /* Test decode off end of array */ \
-    macro(({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}), 2, false, 0x0, 0lu) \
-
-
-#define TEST_SIGNED_LEB_DECODE(init, startOffset, expectedStatus, expectedResult, expectedOffset) \
-    { \
-        Vector&lt;uint8_t&gt; vector = Vector&lt;uint8_t&gt; init; \
-        size_t offset = startOffset; \
-        int32_t result; \
-        bool status = WTF::LEBDecoder::decodeInt32(vector.data(), vector.size(), offset, result); \
-        CHECK_EQ(status, expectedStatus); \
-        if (expectedStatus) { \
-            int32_t expected = expectedResult; \
-            CHECK_EQ(result, expected); \
-            CHECK_EQ(offset, expectedOffset); \
-        } \
-    };
-
-
-static void runLEBTests()
-{
-    FOR_EACH_UNSIGNED_LEB_TEST(TEST_UNSIGNED_LEB_DECODE)
-    FOR_EACH_SIGNED_LEB_TEST(TEST_SIGNED_LEB_DECODE)
-}
-
</del><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> 
</span><span class="cx"> static JSC::VM* vm;
</span><span class="lines">@@ -1438,9 +1328,6 @@
</span><span class="cx"> {
</span><span class="cx">     CommandLine options(argc, argv);
</span><span class="cx"> 
</span><del>-    if (options.m_runLEBTests)
-        runLEBTests();
-
</del><span class="cx">     if (options.m_runWasmTests) {
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx">         JSC::initializeThreading();
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (209541 => 209542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-12-08 17:46:41 UTC (rev 209541)
+++ trunk/Tools/ChangeLog        2016-12-08 17:59:52 UTC (rev 209542)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-12-08  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Move LEB tests to API tests
+        https://bugs.webkit.org/show_bug.cgi?id=165586
+
+        Reviewed by Saam Barati.
+
+        Move the tests from testWasm.cpp and make them functions
+        rather than macros.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/LEBDecoder.cpp: Added.
+        (TestWebKitAPI::testUnsignedLEBDecode):
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::testInt32LEBDecode):
+
</ins><span class="cx"> 2016-12-08  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support running the layout tests offline
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (209541 => 209542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-12-08 17:46:41 UTC (rev 209541)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-12-08 17:59:52 UTC (rev 209542)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx">                 52B8CF9815868D9100281053 /* SetDocumentURI.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 52B8CF9415868CF000281053 /* SetDocumentURI.html */; };
</span><span class="cx">                 52D673EE1AFB127300FA19FE /* WKPageCopySessionStateWithFiltering.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */; };
</span><span class="cx">                 52E5CE4914D21EAB003B2BD8 /* ParentFrame_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */; };
</span><ins>+                531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 531C1D8D1DF8EF72006E979F /* LEBDecoder.cpp */; };
</ins><span class="cx">                 536770341CC8022800D425B1 /* WebScriptObjectDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 536770331CC8022800D425B1 /* WebScriptObjectDescription.mm */; };
</span><span class="cx">                 536770361CC81B6100D425B1 /* WebScriptObjectDescription.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */; };
</span><span class="cx">                 5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */; };
</span><span class="lines">@@ -958,6 +959,7 @@
</span><span class="cx">                 52D673EC1AFB126800FA19FE /* WKPageCopySessionStateWithFiltering.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageCopySessionStateWithFiltering.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52E5CE4514D21E9D003B2BD8 /* ParentFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParentFrame_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                531C1D8D1DF8EF72006E979F /* LEBDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LEBDecoder.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 536770331CC8022800D425B1 /* WebScriptObjectDescription.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptObjectDescription.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebScriptObjectDescription.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronizedFixedQueue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1866,6 +1868,7 @@
</span><span class="cx">                                 26F1B44315CA434F00D1E4BF /* StringImpl.cpp */,
</span><span class="cx">                                 C01363C713C3997300EF3964 /* StringOperators.cpp */,
</span><span class="cx">                                 7C74D42D188228F300E5ED57 /* StringView.cpp */,
</span><ins>+                                531C1D8D1DF8EF72006E979F /* LEBDecoder.cpp */,
</ins><span class="cx">                                 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */,
</span><span class="cx">                                 0BCD85691485C98B00EA2003 /* SetForScope.cpp */,
</span><span class="cx">                                 9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */,
</span><span class="lines">@@ -2355,6 +2358,7 @@
</span><span class="cx">                                 7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
</span><span class="cx">                                 7C83DEF61D0A590C00FEBCF3 /* MetaAllocator.cpp in Sources */,
</span><span class="cx">                                 7C83DEFE1D0A590C00FEBCF3 /* NakedPtr.cpp in Sources */,
</span><ins>+                                531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */,
</ins><span class="cx">                                 7C83DF011D0A590C00FEBCF3 /* Optional.cpp in Sources */,
</span><span class="cx">                                 ADCEBBA61D9AE229002E283A /* Consume.cpp in Sources */,
</span><span class="cx">                                 AD7C434D1DD2A54E0026888B /* Expected.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFLEBDecodercpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/LEBDecoder.cpp (0 => 209542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/LEBDecoder.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/LEBDecoder.cpp        2016-12-08 17:59:52 UTC (rev 209542)
</span><span class="lines">@@ -0,0 +1,127 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#include &lt;wtf/LEBDecoder.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace TestWebKitAPI {
+
+static void testUnsignedLEBDecode(std::initializer_list&lt;uint8_t&gt; data, size_t startOffset, bool expectedStatus, uint32_t expectedResult, size_t expectedOffset)
+{
+    Vector&lt;uint8_t&gt; vector(data);
+    uint32_t result;
+    bool status = WTF::LEBDecoder::decodeUInt32(vector.data(), vector.size(), startOffset, result);
+    EXPECT_EQ(status, expectedStatus);
+    if (expectedStatus) {
+        EXPECT_EQ(result, expectedResult);
+        EXPECT_EQ(startOffset, expectedOffset);
+    }
+}
+
+TEST(WTF, LEBDecoderUInt32)
+{
+    // Simple tests that use all the bits in the array
+    testUnsignedLEBDecode({ 0x07 }, 0, true, 0x7lu, 1lu);
+    testUnsignedLEBDecode({ 0x77 }, 0, true, 0x77lu, 1lu);
+    testUnsignedLEBDecode({ 0x80, 0x07 }, 0, true, 0x380lu, 2lu);
+    testUnsignedLEBDecode({ 0x89, 0x12 }, 0, true, 0x909lu, 2lu);
+    testUnsignedLEBDecode({ 0xf3, 0x85, 0x02 }, 0, true, 0x82f3lu, 3lu);
+    testUnsignedLEBDecode({ 0xf3, 0x85, 0xff, 0x74 }, 0, true, 0xe9fc2f3lu, 4lu);
+    testUnsignedLEBDecode({ 0xf3, 0x85, 0xff, 0xf4, 0x7f }, 0, true, 0xfe9fc2f3lu, 5lu);
+    // Test with extra trailing numbers
+    testUnsignedLEBDecode({ 0x07, 0x80 }, 0, true, 0x7lu, 1lu);
+    testUnsignedLEBDecode({ 0x07, 0x75 }, 0, true, 0x7lu, 1lu);
+    testUnsignedLEBDecode({ 0xf3, 0x85, 0xff, 0x74, 0x43 }, 0, true, 0xe9fc2f3lu, 4lu);
+    testUnsignedLEBDecode({ 0xf3, 0x85, 0xff, 0x74, 0x80 }, 0, true, 0xe9fc2f3lu, 4lu);
+    // Test with preceeding numbers
+    testUnsignedLEBDecode({ 0xf3, 0x07 }, 1, true, 0x7lu, 2lu);
+    testUnsignedLEBDecode({ 0x03, 0x07 }, 1, true, 0x7lu, 2lu);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77 }, 5, true, 0x77lu, 6lu);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77 }, 5, true, 0x77lu, 6ul);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02 }, 3, true, 0x82f3lu, 6lu);
+    // Test in the middle
+    testUnsignedLEBDecode({ 0xf3, 0x07, 0x89 }, 1, true, 0x7lu, 2lu);
+    testUnsignedLEBDecode({ 0x03, 0x07, 0x23 }, 1, true, 0x7lu, 2lu);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77, 0x43 }, 5, true, 0x77lu, 6lu);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77, 0xf9 }, 5, true, 0x77lu, 6lu);
+    testUnsignedLEBDecode({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02, 0xa4 }, 3, true, 0x82f3lu, 6lu);
+    // Test decode too long
+    testUnsignedLEBDecode({ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}, 0, false, 0x0lu, 0lu);
+    testUnsignedLEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 1, false, 0x0lu, 0lu);
+    testUnsignedLEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 0, false, 0x0lu, 0lu);
+    // Test decode off end of array
+    testUnsignedLEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 2, false, 0x0lu, 0lu);
+}
+
+static void testInt32LEBDecode(std::initializer_list&lt;uint8_t&gt; data, size_t startOffset, bool expectedStatus, int32_t expectedResult, size_t expectedOffset)
+{
+    Vector&lt;uint8_t&gt; vector(data);
+    int32_t result;
+    bool status = WTF::LEBDecoder::decodeInt32(vector.data(), vector.size(), startOffset, result);
+    EXPECT_EQ(status, expectedStatus);
+    if (expectedStatus) {
+        EXPECT_EQ(result, expectedResult);
+        EXPECT_EQ(startOffset, expectedOffset);
+    }
+}
+
+TEST(WTF, LEBDecoderInt32)
+{
+    // Simple tests that use all the bits in the array
+    testInt32LEBDecode({ 0x07 }, 0, true, 0x7, 1lu);
+    testInt32LEBDecode({ 0x77 }, 0, true, -0x9, 1lu);
+    testInt32LEBDecode({ 0x80, 0x07 }, 0, true, 0x380, 2lu);
+    testInt32LEBDecode({ 0x89, 0x12 }, 0, true, 0x909, 2lu);
+    testInt32LEBDecode({ 0xf3, 0x85, 0x02 }, 0, true, 0x82f3, 3lu);
+    testInt32LEBDecode({ 0xf3, 0x85, 0xff, 0x74 }, 0, true, 0xfe9fc2f3, 4lu);
+    testInt32LEBDecode({ 0xf3, 0x85, 0xff, 0xf4, 0x7f }, 0, true, 0xfe9fc2f3, 5lu);
+    // Test with extra trailing numbers
+    testInt32LEBDecode({ 0x07, 0x80 }, 0, true, 0x7, 1lu);
+    testInt32LEBDecode({ 0x07, 0x75 }, 0, true, 0x7, 1lu);
+    testInt32LEBDecode({ 0xf3, 0x85, 0xff, 0x74, 0x43 }, 0, true, 0xfe9fc2f3, 4lu);
+    testInt32LEBDecode({ 0xf3, 0x85, 0xff, 0x74, 0x80 }, 0, true, 0xfe9fc2f3, 4lu);
+    // Test with preceeding numbers
+    testInt32LEBDecode({ 0xf3, 0x07 }, 1, true, 0x7, 2lu);
+    testInt32LEBDecode({ 0x03, 0x07 }, 1, true, 0x7, 2lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77 }, 5, true, -0x9, 6lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77 }, 5, true, -0x9, 6lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02 }, 3, true, 0x82f3, 6lu);
+    // Test in the middle
+    testInt32LEBDecode({ 0xf3, 0x07, 0x89 }, 1, true, 0x7, 2lu);
+    testInt32LEBDecode({ 0x03, 0x07, 0x23 }, 1, true, 0x7, 2lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0x67, 0x79, 0x77, 0x43 }, 5, true, -0x9, 6lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0xf7, 0x84, 0x77, 0xf9 }, 5, true, -0x9, 6lu);
+    testInt32LEBDecode({ 0xf2, 0x53, 0x43, 0xf3, 0x85, 0x02, 0xa4 }, 3, true, 0x82f3, 6lu);
+    // Test decode too long
+    testInt32LEBDecode({ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}, 0, false, 0x0, 0lu);
+    testInt32LEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 1, false, 0x0, 0lu);
+    testInt32LEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 0, false, 0x0, 0lu);
+    // Test decode off end of array
+    testInt32LEBDecode({ 0x80, 0x80, 0xab, 0x8a, 0x9a, 0xa3, 0xff}, 2, false, 0x0, 0lu);
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>

</body>
</html>