Changeset 270149 in webkit
- Timestamp:
- Nov 21, 2020 11:08:51 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270148 r270149 1 2020-11-21 Brian Burg <bburg@apple.com> 2 3 Web Inspector: implement Multimap.prototype.take() 4 https://bugs.webkit.org/show_bug.cgi?id=219231 5 6 Reviewed by Devin Rousso. 7 8 * inspector/unit-tests/multimap-expected.txt: 9 * inspector/unit-tests/multimap.html: 10 * inspector/unit-tests/set-utilities.html: 11 1 12 2020-11-21 Aditya Keerthi <akeerthi@apple.com> 2 13 -
trunk/LayoutTests/inspector/unit-tests/multimap-expected.txt
r243264 r270149 58 58 [["raccoon","opossum"]] 59 59 60 -- Running test case: Multimap.prototype.take.SingleKeyAndValue 61 [[0,1],[2,3],[2,4]] 62 1 63 PASS: The key 0 and the value 1 were taken. 64 PASS: Only one key should remain. 65 [[2,3],[2,4]] 66 undefined 67 PASS: Nothing should have been taken. 68 PASS: Only one key should remain. 69 [[2,3],[2,4]] 70 3 71 PASS: The key 2 and the value 3 were taken. 72 PASS: Only one key should remain. 73 [[2,4]] 74 4 75 PASS: The key 2 and the value 4 were taken. 76 PASS: No more keys should remain. 77 [] 78 79 -- Running test case: Multimap.prototype.take.AllValuesForKey 80 [["opossum","badger"],["opossum","raccoon"],["raccoon","opossum"]] 81 PASS: Nothing was removed for key "badger". 82 [["opossum","badger"],["opossum","raccoon"],["raccoon","opossum"]] 83 PASS: Only one key should remain. 84 PASS: Two values from the key "opossum" should be taken. 85 PASS: Result should include "badger". 86 PASS: Result should include "raccoon". 87 [["raccoon","opossum"]] 88 60 89 -- Running test case: Multimap.prototype.clear 61 90 [["one","two"],["one","five"],["three","four"],["three","six"]] -
trunk/LayoutTests/inspector/unit-tests/multimap.html
r243264 r270149 166 166 167 167 suite.addTestCase({ 168 name: "Multimap.prototype.take.SingleKeyAndValue", 169 test() { 170 let multimap = new Multimap; 171 let result; 172 173 multimap.add(0, 1); 174 multimap.add(2, 3); 175 multimap.add(2, 4); 176 177 InspectorTest.log(multimap); 178 179 result = multimap.take(0, 1); 180 InspectorTest.log(result); 181 InspectorTest.expectEqual(result, 1, "The key 0 and the value 1 were taken."); 182 InspectorTest.expectEqual(multimap.size, 1, "Only one key should remain."); 183 184 InspectorTest.log(multimap); 185 186 result = multimap.take(5, 1); 187 InspectorTest.log(result); 188 InspectorTest.expectEqual(result, undefined, "Nothing should have been taken."); 189 InspectorTest.expectEqual(multimap.size, 1, "Only one key should remain."); 190 191 InspectorTest.log(multimap); 192 193 result = multimap.take(2, 3) 194 InspectorTest.log(result); 195 InspectorTest.expectEqual(result, 3, "The key 2 and the value 3 were taken."); 196 InspectorTest.expectEqual(multimap.size, 1, "Only one key should remain."); 197 198 InspectorTest.log(multimap); 199 200 result = multimap.take(2, 4) 201 InspectorTest.log(result); 202 InspectorTest.expectEqual(result, 4, "The key 2 and the value 4 were taken."); 203 InspectorTest.expectEqual(multimap.size, 0, "No more keys should remain."); 204 205 InspectorTest.log(multimap); 206 }, 207 }); 208 209 suite.addTestCase({ 210 name: "Multimap.prototype.take.AllValuesForKey", 211 test() { 212 let multimap = new Multimap; 213 214 multimap.add("opossum", "badger"); 215 multimap.add("opossum", "raccoon"); 216 multimap.add("raccoon", "opossum"); 217 218 InspectorTest.log(multimap); 219 InspectorTest.expectFalse(multimap.take("badger"), `Nothing was removed for key "badger".`); 220 221 InspectorTest.log(multimap); 222 223 let result = multimap.take("opossum"); 224 InspectorTest.expectEqual(multimap.size, 1, `Only one key should remain.`); 225 InspectorTest.expectEqual(result.size, 2, `Two values from the key "opossum" should be taken.`); 226 InspectorTest.expectThat(result.has("badger"), `Result should include "badger".`); 227 InspectorTest.expectThat(result.has("raccoon"), `Result should include "raccoon".`); 228 229 InspectorTest.log(multimap); 230 }, 231 }); 232 233 suite.addTestCase({ 168 234 name: "Multimap.prototype.clear", 169 235 test() { -
trunk/LayoutTests/inspector/unit-tests/set-utilities.html
r262806 r270149 107 107 let set = new Set; 108 108 set.add(key); 109 InspectorTest.expect True(set.take(key), "Set can take `key`.");109 InspectorTest.expectEqual(set.take(key), key, "Set can take `key`."); 110 110 InspectorTest.expectFalse(set.has(key), "Set no longer has `key`."); 111 InspectorTest.expect False(set.take(key), "Set can NOT take `key`.");112 InspectorTest.expect False(set.take("DNE"), "Set can NOT take `DNE`, as it does NOT exist.");111 InspectorTest.expectEqual(set.take(key), undefined, "Set can NOT take `key`."); 112 InspectorTest.expectEqual(set.take("DNE"), undefined, "Set can NOT take `DNE`, as it does NOT exist."); 113 113 } 114 114 }); -
trunk/Source/WebInspectorUI/ChangeLog
r270134 r270149 1 2020-11-21 Brian Burg <bburg@apple.com> 2 3 Web Inspector: implement Multimap.prototype.take() 4 https://bugs.webkit.org/show_bug.cgi?id=219231 5 6 Reviewed by Devin Rousso. 7 8 * UserInterface/Base/Multimap.js: 9 (Multimap.prototype.take): 10 * UserInterface/Base/Utilities.js: 11 (value): 12 1 13 2020-11-20 Devin Rousso <drousso@apple.com> 2 14 -
trunk/Source/WebInspectorUI/UserInterface/Base/Multimap.js
r247053 r270149 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 84 84 } 85 85 86 take(key, value) 87 { 88 // Allow an entire key to be removed by not passing a value. 89 if (arguments.length === 1) 90 return this._map.take(key); 91 92 let valueSet = this._map.get(key); 93 if (!valueSet) 94 return undefined; 95 96 let result = valueSet.take(value); 97 if (!valueSet.size) 98 this._map.delete(key); 99 return result; 100 } 101 86 102 clear() 87 103 { -
trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js
r268634 r270149 179 179 value(key) 180 180 { 181 let exists = this.has(key); 182 if (exists) 181 if (this.has(key)) { 183 182 this.delete(key); 184 return exists; 183 return key; 184 } 185 186 return undefined; 185 187 } 186 188 });
Note: See TracChangeset
for help on using the changeset viewer.