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

Side by Side Diff: test/mjsunit/harmony/object-values.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.values.length);
9 assertEquals(Function.prototype, Object.getPrototypeOf(Object.values));
10 }
11 TestMeta();
12
13
14 function TestBasic() {
15 var O = {
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([123, 456, 1, 3, 2, 4], Object.values(O));
26 assertEquals(Object.values(O), Object.keys(O).map(key => O[key]));
27 }
28 TestBasic();
29
30
31 function TestOrder() {
32 var O = {
33 a: 1,
34 [Symbol.iterator]: null
35 };
36 O[456] = 123;
37 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
38
39 var log = [];
40 var P = new Proxy(O, {
41 ownKeys(target) {
42 log.push("[[OwnPropertyKeys]]");
43 return Reflect.ownKeys(target);
44 },
45 get(target, name) {
46 log.push(`[[Get]](${JSON.stringify(name)})`);
47 return Reflect.get(target, name);
48 },
49 set(target, name, value) {
50 assertUnreachable();
51 }
52 });
53
54 assertEquals([123, 1], Object.values(P));
55 assertEquals([
56 "[[OwnPropertyKeys]]",
57 "[[Get]](\"456\")",
58 "[[Get]](\"a\")"
59 ], log);
60 }
61 TestOrder();
OLDNEW
« test/mjsunit/harmony/object-entries.js ('K') | « test/mjsunit/harmony/object-entries.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698