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

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: 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
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 --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 O = {
rossberg 2016/01/14 13:18:43 Maybe add a computed property name.
caitp (gmail) 2016/01/14 14:13:24 Done.
16 d: 1,
17 c: 3,
18 [Symbol.iterator]: void 0,
19 0: 123,
20 1000: 456
21 };
22 O.a = 2;
23 O.b = 4;
24 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
25 assertEquals([
26 ["0", 123],
27 ["1000", 456],
28 ["d", 1],
29 ["c", 3],
30 ["a", 2],
31 ["b", 4]
32 ], Object.entries(O));
33 assertEquals(Object.entries(O), Object.keys(O).map(key => [key, O[key]]));
34 }
35 TestBasic();
36
37
38 function TestOrder() {
39 var O = {
40 a: 1,
41 [Symbol.iterator]: null
42 };
43 O[456] = 123;
44 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
45
46 var log = [];
47 var P = new Proxy(O, {
48 ownKeys(target) {
49 log.push("[[OwnPropertyKeys]]");
50 return Reflect.ownKeys(target);
51 },
52 get(target, name) {
53 log.push(`[[Get]](${JSON.stringify(name)})`);
54 return Reflect.get(target, name);
55 },
56 set(target, name, value) {
57 assertUnreachable();
58 }
59 });
60
61 assertEquals([["456", 123], ["a", 1]], Object.entries(P));
62 assertEquals([
63 "[[OwnPropertyKeys]]",
64 "[[Get]](\"456\")",
65 "[[Get]](\"a\")"
66 ], log);
67 }
68 TestOrder();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698