Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: test/mjsunit/harmony/object-values.js

Issue 1767113004: [esnext] handle elements in FastObjectValuesOrEntries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make ElementsAccessor::GetCapacity() public, and use it Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/harmony/object-entries.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-object-values-entries --harmony-proxies --harmony-reflect 5 // Flags: --harmony-object-values-entries --harmony-proxies --harmony-reflect
6 // Flags: --allow-natives-syntax 6 // Flags: --allow-natives-syntax
7 7
8 function TestMeta() { 8 function TestMeta() {
9 assertEquals(1, Object.values.length); 9 assertEquals(1, Object.values.length);
10 assertEquals(Function.prototype, Object.getPrototypeOf(Object.values)); 10 assertEquals(Function.prototype, Object.getPrototypeOf(Object.values));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 Object.defineProperty(this, "b", { enumerable: true }); 220 Object.defineProperty(this, "b", { enumerable: true });
221 return 1; 221 return 1;
222 }, 222 },
223 enumerable: true 223 enumerable: true
224 }); 224 });
225 Object.defineProperty(aMakesBEnumerable, "b", { 225 Object.defineProperty(aMakesBEnumerable, "b", {
226 value: 2, configurable:true, enumerable: false }); 226 value: 2, configurable:true, enumerable: false });
227 assertEquals([1, 2], Object.values(aMakesBEnumerable)); 227 assertEquals([1, 2], Object.values(aMakesBEnumerable));
228 } 228 }
229 TestMutateDuringEnumeration(); 229 TestMutateDuringEnumeration();
230
231
232 (function TestElementKinds() {
233 var O1 = { name: "1" }, O2 = { name: "2" }, O3 = { name: "3" };
234 var PI = 3.141592653589793;
235 var E = 2.718281828459045;
236 function fastSloppyArguments(a, b, c) {
237 delete arguments[0];
238 arguments[0] = a;
239 return arguments;
240 }
241
242 function slowSloppyArguments(a, b, c) {
243 delete arguments[0];
244 arguments[0] = a;
245 Object.defineProperties(arguments, {
246 0: {
247 enumerable: true,
248 value: a
249 },
250 9999: {
251 enumerable: false,
252 value: "Y"
253 }
254 });
255 arguments[10000] = "X";
256 return arguments;
257 }
258
259 var element_kinds = {
260 FAST_SMI_ELEMENTS: [ [1, 2, 3], [1, 2, 3] ],
261 FAST_HOLEY_SMI_ELEMENTS: [ [, , 3], [ 3 ] ],
262 FAST_ELEMENTS: [ [O1, O2, O3], [O1, O2, O3] ],
263 FAST_HOLEY_ELEMENTS: [ [, , O3], [O3] ],
264 FAST_DOUBLE_ELEMENTS: [ [E, NaN, PI], [E, NaN, PI] ],
265 FAST_HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [NaN] ],
266
267 DICTIONARY_ELEMENTS: [ Object.defineProperties({ 10000: "world" }, {
268 100: { enumerable: true, value: "hello" },
269 99: { enumerable: false, value: "nope" }
270 }), [ "hello", "world" ] ],
271 FAST_SLOPPY_ARGUMENTS_ELEMENTS: [
272 fastSloppyArguments("a", "b", "c"), ["a", "b", "c"] ],
273 SLOW_SLOPPY_ARGUMENTS_ELEMENTS: [
274 slowSloppyArguments("a", "b", "c"), [ "a", "b", "c", "X"]],
275
276 FAST_STRING_WRAPPER_ELEMENTS: [ new String("str"), ["s", "t", "r"] ],
277 SLOW_STRING_WRAPPER_ELEMENTS: [
278 Object.defineProperties(new String("str"), {
279 10000: { enumerable: false, value: "X" },
280 9999: { enumerable: true, value: "Y" }
281 }), ["s", "t", "r", "Y"] ],
282 };
283
284 for (let [kind, [object, expected]] of Object.entries(element_kinds)) {
285 let result1 = Object.values(object);
286 assertEquals(expected, result1, `fast Object.values() with ${kind}`);
287
288 let proxy = new Proxy(object, {});
289 let result2 = Object.values(proxy);
290 assertEquals(result1, result2, `slow Object.values() with ${kind}`);
291 }
292 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/object-entries.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698