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

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

Issue 1581033002: [es7] implement Object.values() / Object.entries() proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Execution::ToObject() -> Object::ToObject(), test fixups Created 4 years, 11 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 | « src/heap/heap.h ('k') | test/mjsunit/harmony/object-values.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-object-values-entries --harmony-proxies --harmony-reflect
6
7 function TestMeta() {
8 assertEquals(1, Object.entries.length);
9 assertEquals(Function.prototype, Object.getPrototypeOf(Object.entries));
10 }
11 TestMeta();
12
13
14 function TestBasic() {
15 var x = 16;
16 var O = {
17 d: 1,
18 c: 3,
19 [Symbol.iterator]: void 0,
20 0: 123,
21 1000: 456,
22 [x * x]: "ducks",
23 [`0x${(x * x).toString(16)}`]: "quack"
24 };
25 O.a = 2;
26 O.b = 4;
27 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
28 assertEquals([
29 ["0", 123],
30 ["256", "ducks"],
31 ["1000", 456],
32 ["d", 1],
33 ["c", 3],
34 ["0x100", "quack"],
35 ["a", 2],
36 ["b", 4]
37 ], Object.entries(O));
38 assertEquals(Object.entries(O), Object.keys(O).map(key => [key, O[key]]));
39 }
40 TestBasic();
41
42
43 function TestOrder() {
44 var O = {
45 a: 1,
46 [Symbol.iterator]: null
47 };
48 O[456] = 123;
49 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
50
51 var log = [];
52 var P = new Proxy(O, {
53 ownKeys(target) {
54 log.push("[[OwnPropertyKeys]]");
55 return Reflect.ownKeys(target);
56 },
57 get(target, name) {
58 log.push(`[[Get]](${JSON.stringify(name)})`);
59 return Reflect.get(target, name);
60 },
61 set(target, name, value) {
62 assertUnreachable();
63 }
64 });
65
66 assertEquals([["456", 123], ["a", 1]], Object.entries(P));
67 assertEquals([
68 "[[OwnPropertyKeys]]",
69 "[[Get]](\"456\")",
70 "[[Get]](\"a\")"
71 ], log);
72 }
73 TestOrder();
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | test/mjsunit/harmony/object-values.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698