Changeset 206085 in webkit
- Timestamp:
- Sep 18, 2016 12:49:28 PM (8 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206063 r206085 1 2016-09-18 Matt Baker <mattbaker@apple.com> 2 3 Web Inspector: Add test coverage for all array utility functions 4 https://bugs.webkit.org/show_bug.cgi?id=162044 5 <rdar://problem/28330846> 6 7 Reviewed by Joseph Pecoraro. 8 9 New test cases and expectations for Array utility functions. 10 11 * inspector/unit-tests/array-utilities-expected.txt: 12 * inspector/unit-tests/array-utilities.html: 13 1 14 2016-09-16 Joseph Pecoraro <pecoraro@apple.com> 2 15 -
trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt
r205872 r206085 46 46 PASS: shallowEqual of non-arrays should be false. 47 47 48 -- Running test case: Array.prototype.lastValue 49 PASS: lastValue of a nonempty array should be the last value. 50 PASS: lastValue of an empty array should be undefined. 51 52 -- Running test case: Array.prototype.remove 53 PASS: remove with onlyFirst equal to true should only remove the first matching value. 54 PASS: remove with onlyFirst equal to false should remove all matching values. 55 PASS: remove with onlyFirst unspecified should remove all matching values. 56 57 -- Running test case: Array.prototype.toggleIncludes 58 PASS: toggleIncludes of an existing item with force true should have no effect. 59 PASS: toggleIncludes of an existing item with force false should remove the item. 60 PASS: toggleIncludes of a nonexistent item with force true should add the item. 61 PASS: toggleIncludes of a nonexistent item with force false should have no effect. 62 63 -- Running test case: Array.prototype.insertAtIndex 64 PASS: insertAtIndex with index unspecified should insert at the beginning. 65 PASS: insertAtIndex with index zero should insert at the beginning. 66 PASS: insertAtIndex with 0 < index < length should insert at the correct location. 67 PASS: insertAtIndex with negative index should insert from the end. 68 PASS: insertAtIndex with index greater than array length should insert at the end. 69 70 -- Running test case: Array.prototype.keySet 71 PASS: keySet should create an object with keys equal to the array values. 72 PASS: keySet should create an object with all values equal to true. 73 PASS: keySet should create an object with keys equal to stringified array values. 74 -
trunk/LayoutTests/inspector/unit-tests/array-utilities.html
r205872 r206085 10 10 suite.addTestCase({ 11 11 name: "Array.prototype.lowerBound", 12 test : () =>{12 test() { 13 13 // Index: 0 1 2 3 4 5 6 7 8 9 14 14 let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7]; … … 31 31 suite.addTestCase({ 32 32 name: "Array.prototype.upperBound", 33 test : () =>{33 test() { 34 34 // Index: 0 1 2 3 4 5 6 7 8 9 35 35 let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7]; … … 52 52 suite.addTestCase({ 53 53 name: "Array.prototype.binaryIndexOf", 54 test : () =>{54 test() { 55 55 // Index: 0 1 2 3 4 5 6 7 8 9 56 56 let arr = [0, 1, 2, 2, 2, 2, 2, 2, 6, 7]; … … 66 66 suite.addTestCase({ 67 67 name: "Array.prototype.partition", 68 test : () =>{68 test() { 69 69 let arr1 = [1, 2, 3, 4]; 70 70 let [even, odd] = arr1.partition((x) => x % 2 === 0); … … 88 88 suite.addTestCase({ 89 89 name: "Array.shallowEqual", 90 test : () =>{90 test() { 91 91 InspectorTest.expectThat(Array.shallowEqual([], []), "shallowEqual of empty arrays should be true."); 92 92 … … 108 108 InspectorTest.expectFalse(Array.shallowEqual(str, str), "shallowEqual of a non-array with itself should be false."); 109 109 InspectorTest.expectFalse(Array.shallowEqual({}, {}), "shallowEqual of non-arrays should be false."); 110 111 return true; 112 } 113 }); 114 115 suite.addTestCase({ 116 name: "Array.prototype.lastValue", 117 test() { 118 let object1 = {}; 119 let object2 = {}; 120 InspectorTest.expectEqual([object1, object2].lastValue, object2, "lastValue of a nonempty array should be the last value.") 121 InspectorTest.expectEqual([].lastValue, undefined, "lastValue of an empty array should be undefined.") 122 123 return true; 124 } 125 }); 126 127 suite.addTestCase({ 128 name: "Array.prototype.remove", 129 test() { 130 let arr1 = [1, 2, 3, 1]; 131 arr1.remove(1, true); 132 // Note: Array.prototype.remove starts searching from the end of the array. 133 InspectorTest.expectShallowEqual(arr1, [1, 2, 3], "remove with onlyFirst equal to true should only remove the first matching value."); 134 135 let arr2 = [1, 2, 3, 1]; 136 arr2.remove(1, false); 137 InspectorTest.expectShallowEqual(arr2, [2, 3], "remove with onlyFirst equal to false should remove all matching values."); 138 139 let arr3 = [1, 2, 3, 1]; 140 arr3.remove(1); 141 InspectorTest.expectShallowEqual(arr3, [2, 3], "remove with onlyFirst unspecified should remove all matching values."); 142 143 return true; 144 } 145 }); 146 147 suite.addTestCase({ 148 name: "Array.prototype.toggleIncludes", 149 test() { 150 let arr1 = [1, 2, 3]; 151 arr1.toggleIncludes(3, true); 152 InspectorTest.expectShallowEqual(arr1, [1, 2, 3], "toggleIncludes of an existing item with force true should have no effect."); 153 154 let arr2 = [1, 2, 3]; 155 arr2.toggleIncludes(3, false); 156 InspectorTest.expectShallowEqual(arr2, [1, 2], "toggleIncludes of an existing item with force false should remove the item."); 157 158 let arr3 = [1, 2, 3]; 159 arr3.toggleIncludes(4, true); 160 InspectorTest.expectShallowEqual(arr3, [1, 2, 3, 4], "toggleIncludes of a nonexistent item with force true should add the item."); 161 162 let arr4 = [1, 2, 3]; 163 arr4.toggleIncludes(4, false); 164 InspectorTest.expectShallowEqual(arr4, [1, 2, 3], "toggleIncludes of a nonexistent item with force false should have no effect."); 165 166 return true; 167 } 168 }); 169 170 suite.addTestCase({ 171 name: "Array.prototype.insertAtIndex", 172 test() { 173 let arr1 = [1, 2, 3]; 174 arr1.insertAtIndex("x"); 175 InspectorTest.expectShallowEqual(arr1, ["x", 1, 2, 3], "insertAtIndex with index unspecified should insert at the beginning."); 176 177 let arr2 = [1, 2, 3]; 178 arr2.insertAtIndex("x", 0); 179 InspectorTest.expectShallowEqual(arr2, ["x", 1, 2, 3], "insertAtIndex with index zero should insert at the beginning."); 180 181 let arr3 = [1, 2, 3]; 182 arr3.insertAtIndex("x", 2); 183 InspectorTest.expectShallowEqual(arr3, [1, 2, "x", 3], "insertAtIndex with 0 < index < length should insert at the correct location."); 184 185 let arr4 = [1, 2, 3]; 186 arr4.insertAtIndex("x", -1); 187 InspectorTest.expectShallowEqual(arr4, [1, 2, "x", 3], "insertAtIndex with negative index should insert from the end."); 188 189 let arr5 = [1, 2, 3]; 190 arr5.insertAtIndex("x", 100); 191 InspectorTest.expectShallowEqual(arr5, [1, 2, 3, "x"], "insertAtIndex with index greater than array length should insert at the end."); 192 193 return true; 194 } 195 }); 196 197 suite.addTestCase({ 198 name: "Array.prototype.keySet", 199 test() { 200 let arr1 = ["abc", "def", "xyz"]; 201 let keySet = arr1.keySet(); 202 InspectorTest.expectShallowEqual(Object.keys(keySet), arr1, "keySet should create an object with keys equal to the array values."); 203 InspectorTest.expectShallowEqual(Object.values(keySet), [true, true, true], "keySet should create an object with all values equal to true."); 204 205 let arr2 = [1, 2, 3]; 206 InspectorTest.expectShallowEqual(Object.keys(arr2.keySet()), arr2.map(x => x.toString()), "keySet should create an object with keys equal to stringified array values."); 110 207 111 208 return true;
Note: See TracChangeset
for help on using the changeset viewer.