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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | test/mjsunit/harmony/object-values.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/object-entries.js
diff --git a/test/mjsunit/harmony/object-entries.js b/test/mjsunit/harmony/object-entries.js
new file mode 100644
index 0000000000000000000000000000000000000000..47fedd1980be55488eccf757bbb88b5efc2446e6
--- /dev/null
+++ b/test/mjsunit/harmony/object-entries.js
@@ -0,0 +1,73 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-object-values-entries --harmony-proxies --harmony-reflect
+
+function TestMeta() {
+ assertEquals(1, Object.entries.length);
+ assertEquals(Function.prototype, Object.getPrototypeOf(Object.entries));
+}
+TestMeta();
+
+
+function TestBasic() {
+ var x = 16;
+ var O = {
+ d: 1,
+ c: 3,
+ [Symbol.iterator]: void 0,
+ 0: 123,
+ 1000: 456,
+ [x * x]: "ducks",
+ [`0x${(x * x).toString(16)}`]: "quack"
+ };
+ O.a = 2;
+ O.b = 4;
+ Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
+ assertEquals([
+ ["0", 123],
+ ["256", "ducks"],
+ ["1000", 456],
+ ["d", 1],
+ ["c", 3],
+ ["0x100", "quack"],
+ ["a", 2],
+ ["b", 4]
+ ], Object.entries(O));
+ assertEquals(Object.entries(O), Object.keys(O).map(key => [key, O[key]]));
+}
+TestBasic();
+
+
+function TestOrder() {
+ var O = {
+ a: 1,
+ [Symbol.iterator]: null
+ };
+ O[456] = 123;
+ Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });
+
+ var log = [];
+ var P = new Proxy(O, {
+ ownKeys(target) {
+ log.push("[[OwnPropertyKeys]]");
+ return Reflect.ownKeys(target);
+ },
+ get(target, name) {
+ log.push(`[[Get]](${JSON.stringify(name)})`);
+ return Reflect.get(target, name);
+ },
+ set(target, name, value) {
+ assertUnreachable();
+ }
+ });
+
+ assertEquals([["456", 123], ["a", 1]], Object.entries(P));
+ assertEquals([
+ "[[OwnPropertyKeys]]",
+ "[[Get]](\"456\")",
+ "[[Get]](\"a\")"
+ ], log);
+}
+TestOrder();
« 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