<!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>[206085] trunk/LayoutTests</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/206085">206085</a></dd>
<dt>Author</dt> <dd>mattbaker@apple.com</dd>
<dt>Date</dt> <dd>2016-09-18 12:49:28 -0700 (Sun, 18 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Add test coverage for all array utility functions
https://bugs.webkit.org/show_bug.cgi?id=162044
&lt;rdar://problem/28330846&gt;

Reviewed by Joseph Pecoraro.

New test cases and expectations for Array utility functions.

* inspector/unit-tests/array-utilities-expected.txt:
* inspector/unit-tests/array-utilities.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorunittestsarrayutilitiesexpectedtxt">trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorunittestsarrayutilitieshtml">trunk/LayoutTests/inspector/unit-tests/array-utilities.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206084 => 206085)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-18 19:04:58 UTC (rev 206084)
+++ trunk/LayoutTests/ChangeLog        2016-09-18 19:49:28 UTC (rev 206085)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-09-18  Matt Baker  &lt;mattbaker@apple.com&gt;
+
+        Web Inspector: Add test coverage for all array utility functions
+        https://bugs.webkit.org/show_bug.cgi?id=162044
+        &lt;rdar://problem/28330846&gt;
+
+        Reviewed by Joseph Pecoraro.
+
+        New test cases and expectations for Array utility functions.
+
+        * inspector/unit-tests/array-utilities-expected.txt:
+        * inspector/unit-tests/array-utilities.html:
+
</ins><span class="cx"> 2016-09-16  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed cleanup of some inspector tests.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorunittestsarrayutilitiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt (206084 => 206085)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt        2016-09-18 19:04:58 UTC (rev 206084)
+++ trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt        2016-09-18 19:49:28 UTC (rev 206085)
</span><span class="lines">@@ -45,3 +45,30 @@
</span><span class="cx"> PASS: shallowEqual of a non-array with itself should be false.
</span><span class="cx"> PASS: shallowEqual of non-arrays should be false.
</span><span class="cx"> 
</span><ins>+-- Running test case: Array.prototype.lastValue
+PASS: lastValue of a nonempty array should be the last value.
+PASS: lastValue of an empty array should be undefined.
+
+-- Running test case: Array.prototype.remove
+PASS: remove with onlyFirst equal to true should only remove the first matching value.
+PASS: remove with onlyFirst equal to false should remove all matching values.
+PASS: remove with onlyFirst unspecified should remove all matching values.
+
+-- Running test case: Array.prototype.toggleIncludes
+PASS: toggleIncludes of an existing item with force true should have no effect.
+PASS: toggleIncludes of an existing item with force false should remove the item.
+PASS: toggleIncludes of a nonexistent item with force true should add the item.
+PASS: toggleIncludes of a nonexistent item with force false should have no effect.
+
+-- Running test case: Array.prototype.insertAtIndex
+PASS: insertAtIndex with index unspecified should insert at the beginning.
+PASS: insertAtIndex with index zero should insert at the beginning.
+PASS: insertAtIndex with 0 &lt; index &lt; length should insert at the correct location.
+PASS: insertAtIndex with negative index should insert from the end.
+PASS: insertAtIndex with index greater than array length should insert at the end.
+
+-- Running test case: Array.prototype.keySet
+PASS: keySet should create an object with keys equal to the array values.
+PASS: keySet should create an object with all values equal to true.
+PASS: keySet should create an object with keys equal to stringified array values.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorunittestsarrayutilitieshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/unit-tests/array-utilities.html (206084 => 206085)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/array-utilities.html        2016-09-18 19:04:58 UTC (rev 206084)
+++ trunk/LayoutTests/inspector/unit-tests/array-utilities.html        2016-09-18 19:49:28 UTC (rev 206085)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;Array.prototype.lowerBound&quot;,
</span><del>-        test: () =&gt; {
</del><ins>+        test() {
</ins><span class="cx">             // Index:  0  1  2  3  4  5  6  7  8  9
</span><span class="cx">             let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7];
</span><span class="cx">             InspectorTest.expectEqual(arr.lowerBound(-100), 0, &quot;lowerBound of a value before the first value should produce the first index.&quot;);
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;Array.prototype.upperBound&quot;,
</span><del>-        test: () =&gt; {
</del><ins>+        test() {
</ins><span class="cx">             // Index:  0  1  2  3  4  5  6  7  8  9
</span><span class="cx">             let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7];
</span><span class="cx">             InspectorTest.expectEqual(arr.upperBound(-100), 0, &quot;upperBound of a value before the first value should produce the first index.&quot;);
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;Array.prototype.binaryIndexOf&quot;,
</span><del>-        test: () =&gt; {
</del><ins>+        test() {
</ins><span class="cx">             // Index:  0  1  2  3  4  5  6  7  8  9
</span><span class="cx">             let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7];
</span><span class="cx">             let defaultComparator = (a, b) =&gt; a - b;
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;Array.prototype.partition&quot;,
</span><del>-        test: () =&gt; {
</del><ins>+        test() {
</ins><span class="cx">             let arr1 = [1, 2, 3, 4];
</span><span class="cx">             let [even, odd] = arr1.partition((x) =&gt; x % 2 === 0);
</span><span class="cx">             InspectorTest.expectEqual(even.length + odd.length, arr1.length, &quot;partition should not lose any elements.&quot;);
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span><span class="cx">         name: &quot;Array.shallowEqual&quot;,
</span><del>-        test: () =&gt; {
</del><ins>+        test() {
</ins><span class="cx">             InspectorTest.expectThat(Array.shallowEqual([], []), &quot;shallowEqual of empty arrays should be true.&quot;);
</span><span class="cx"> 
</span><span class="cx">             let arr1 = [1, 2, 3, 4];
</span><span class="lines">@@ -112,6 +112,103 @@
</span><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span><ins>+    suite.addTestCase({
+        name: &quot;Array.prototype.lastValue&quot;,
+        test() {
+            let object1 = {};
+            let object2 = {};
+            InspectorTest.expectEqual([object1, object2].lastValue, object2, &quot;lastValue of a nonempty array should be the last value.&quot;)
+            InspectorTest.expectEqual([].lastValue, undefined, &quot;lastValue of an empty array should be undefined.&quot;)
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;Array.prototype.remove&quot;,
+        test() {
+            let arr1 = [1, 2, 3, 1];
+            arr1.remove(1, true);
+            // Note: Array.prototype.remove starts searching from the end of the array.
+            InspectorTest.expectShallowEqual(arr1, [1, 2, 3], &quot;remove with onlyFirst equal to true should only remove the first matching value.&quot;);
+
+            let arr2 = [1, 2, 3, 1];
+            arr2.remove(1, false);
+            InspectorTest.expectShallowEqual(arr2, [2, 3], &quot;remove with onlyFirst equal to false should remove all matching values.&quot;);
+
+            let arr3 = [1, 2, 3, 1];
+            arr3.remove(1);
+            InspectorTest.expectShallowEqual(arr3, [2, 3], &quot;remove with onlyFirst unspecified should remove all matching values.&quot;);
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;Array.prototype.toggleIncludes&quot;,
+        test() {
+            let arr1 = [1, 2, 3];
+            arr1.toggleIncludes(3, true);
+            InspectorTest.expectShallowEqual(arr1, [1, 2, 3], &quot;toggleIncludes of an existing item with force true should have no effect.&quot;);
+
+            let arr2 = [1, 2, 3];
+            arr2.toggleIncludes(3, false);
+            InspectorTest.expectShallowEqual(arr2, [1, 2], &quot;toggleIncludes of an existing item with force false should remove the item.&quot;);
+
+            let arr3 = [1, 2, 3];
+            arr3.toggleIncludes(4, true);
+            InspectorTest.expectShallowEqual(arr3, [1, 2, 3, 4], &quot;toggleIncludes of a nonexistent item with force true should add the item.&quot;);
+
+            let arr4 = [1, 2, 3];
+            arr4.toggleIncludes(4, false);
+            InspectorTest.expectShallowEqual(arr4, [1, 2, 3], &quot;toggleIncludes of a nonexistent item with force false should have no effect.&quot;);
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;Array.prototype.insertAtIndex&quot;,
+        test() {
+            let arr1 = [1, 2, 3];
+            arr1.insertAtIndex(&quot;x&quot;);
+            InspectorTest.expectShallowEqual(arr1, [&quot;x&quot;, 1, 2, 3], &quot;insertAtIndex with index unspecified should insert at the beginning.&quot;);
+
+            let arr2 = [1, 2, 3];
+            arr2.insertAtIndex(&quot;x&quot;, 0);
+            InspectorTest.expectShallowEqual(arr2, [&quot;x&quot;, 1, 2, 3], &quot;insertAtIndex with index zero should insert at the beginning.&quot;);
+
+            let arr3 = [1, 2, 3];
+            arr3.insertAtIndex(&quot;x&quot;, 2);
+            InspectorTest.expectShallowEqual(arr3, [1, 2, &quot;x&quot;, 3], &quot;insertAtIndex with 0 &lt; index &lt; length should insert at the correct location.&quot;);
+
+            let arr4 = [1, 2, 3];
+            arr4.insertAtIndex(&quot;x&quot;, -1);
+            InspectorTest.expectShallowEqual(arr4, [1, 2, &quot;x&quot;, 3], &quot;insertAtIndex with negative index should insert from the end.&quot;);
+
+            let arr5 = [1, 2, 3];
+            arr5.insertAtIndex(&quot;x&quot;, 100);
+            InspectorTest.expectShallowEqual(arr5, [1, 2, 3, &quot;x&quot;], &quot;insertAtIndex with index greater than array length should insert at the end.&quot;);
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;Array.prototype.keySet&quot;,
+        test() {
+            let arr1 = [&quot;abc&quot;, &quot;def&quot;, &quot;xyz&quot;];
+            let keySet = arr1.keySet();
+            InspectorTest.expectShallowEqual(Object.keys(keySet), arr1, &quot;keySet should create an object with keys equal to the array values.&quot;);
+            InspectorTest.expectShallowEqual(Object.values(keySet), [true, true, true], &quot;keySet should create an object with all values equal to true.&quot;);
+
+            let arr2 = [1, 2, 3];
+            InspectorTest.expectShallowEqual(Object.keys(arr2.keySet()), arr2.map(x =&gt; x.toString()), &quot;keySet should create an object with keys equal to stringified array values.&quot;);
+
+            return true;
+        }
+    });
+
</ins><span class="cx">     suite.runTestCasesAndFinish();
</span><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span></span></pre>
</div>
</div>

</body>
</html>