<!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
<rdar://problem/28330846>
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 <mattbaker@apple.com>
+
+ Web Inspector: Add test coverage for all array utility functions
+ https://bugs.webkit.org/show_bug.cgi?id=162044
+ <rdar://problem/28330846>
+
+ 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 <pecoraro@apple.com>
</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 < index < 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: "Array.prototype.lowerBound",
</span><del>- test: () => {
</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, "lowerBound of a value before the first value should produce the first index.");
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx">
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "Array.prototype.upperBound",
</span><del>- test: () => {
</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, "upperBound of a value before the first value should produce the first index.");
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "Array.prototype.binaryIndexOf",
</span><del>- test: () => {
</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) => 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: "Array.prototype.partition",
</span><del>- test: () => {
</del><ins>+ test() {
</ins><span class="cx"> let arr1 = [1, 2, 3, 4];
</span><span class="cx"> let [even, odd] = arr1.partition((x) => x % 2 === 0);
</span><span class="cx"> InspectorTest.expectEqual(even.length + odd.length, arr1.length, "partition should not lose any elements.");
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">
</span><span class="cx"> suite.addTestCase({
</span><span class="cx"> name: "Array.shallowEqual",
</span><del>- test: () => {
</del><ins>+ test() {
</ins><span class="cx"> InspectorTest.expectThat(Array.shallowEqual([], []), "shallowEqual of empty arrays should be true.");
</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: "Array.prototype.lastValue",
+ test() {
+ let object1 = {};
+ let object2 = {};
+ InspectorTest.expectEqual([object1, object2].lastValue, object2, "lastValue of a nonempty array should be the last value.")
+ InspectorTest.expectEqual([].lastValue, undefined, "lastValue of an empty array should be undefined.")
+
+ return true;
+ }
+ });
+
+ suite.addTestCase({
+ name: "Array.prototype.remove",
+ 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], "remove with onlyFirst equal to true should only remove the first matching value.");
+
+ let arr2 = [1, 2, 3, 1];
+ arr2.remove(1, false);
+ InspectorTest.expectShallowEqual(arr2, [2, 3], "remove with onlyFirst equal to false should remove all matching values.");
+
+ let arr3 = [1, 2, 3, 1];
+ arr3.remove(1);
+ InspectorTest.expectShallowEqual(arr3, [2, 3], "remove with onlyFirst unspecified should remove all matching values.");
+
+ return true;
+ }
+ });
+
+ suite.addTestCase({
+ name: "Array.prototype.toggleIncludes",
+ test() {
+ let arr1 = [1, 2, 3];
+ arr1.toggleIncludes(3, true);
+ InspectorTest.expectShallowEqual(arr1, [1, 2, 3], "toggleIncludes of an existing item with force true should have no effect.");
+
+ let arr2 = [1, 2, 3];
+ arr2.toggleIncludes(3, false);
+ InspectorTest.expectShallowEqual(arr2, [1, 2], "toggleIncludes of an existing item with force false should remove the item.");
+
+ let arr3 = [1, 2, 3];
+ arr3.toggleIncludes(4, true);
+ InspectorTest.expectShallowEqual(arr3, [1, 2, 3, 4], "toggleIncludes of a nonexistent item with force true should add the item.");
+
+ let arr4 = [1, 2, 3];
+ arr4.toggleIncludes(4, false);
+ InspectorTest.expectShallowEqual(arr4, [1, 2, 3], "toggleIncludes of a nonexistent item with force false should have no effect.");
+
+ return true;
+ }
+ });
+
+ suite.addTestCase({
+ name: "Array.prototype.insertAtIndex",
+ test() {
+ let arr1 = [1, 2, 3];
+ arr1.insertAtIndex("x");
+ InspectorTest.expectShallowEqual(arr1, ["x", 1, 2, 3], "insertAtIndex with index unspecified should insert at the beginning.");
+
+ let arr2 = [1, 2, 3];
+ arr2.insertAtIndex("x", 0);
+ InspectorTest.expectShallowEqual(arr2, ["x", 1, 2, 3], "insertAtIndex with index zero should insert at the beginning.");
+
+ let arr3 = [1, 2, 3];
+ arr3.insertAtIndex("x", 2);
+ InspectorTest.expectShallowEqual(arr3, [1, 2, "x", 3], "insertAtIndex with 0 < index < length should insert at the correct location.");
+
+ let arr4 = [1, 2, 3];
+ arr4.insertAtIndex("x", -1);
+ InspectorTest.expectShallowEqual(arr4, [1, 2, "x", 3], "insertAtIndex with negative index should insert from the end.");
+
+ let arr5 = [1, 2, 3];
+ arr5.insertAtIndex("x", 100);
+ InspectorTest.expectShallowEqual(arr5, [1, 2, 3, "x"], "insertAtIndex with index greater than array length should insert at the end.");
+
+ return true;
+ }
+ });
+
+ suite.addTestCase({
+ name: "Array.prototype.keySet",
+ test() {
+ let arr1 = ["abc", "def", "xyz"];
+ let keySet = arr1.keySet();
+ InspectorTest.expectShallowEqual(Object.keys(keySet), arr1, "keySet should create an object with keys equal to the array values.");
+ InspectorTest.expectShallowEqual(Object.values(keySet), [true, true, true], "keySet should create an object with all values equal to true.");
+
+ let arr2 = [1, 2, 3];
+ InspectorTest.expectShallowEqual(Object.keys(arr2.keySet()), arr2.map(x => x.toString()), "keySet should create an object with keys equal to stringified array values.");
+
+ return true;
+ }
+ });
+
</ins><span class="cx"> suite.runTestCasesAndFinish();
</span><span class="cx"> }
</span><span class="cx"> </script>
</span></span></pre>
</div>
</div>
</body>
</html>