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

Unified Diff: test/mjsunit/harmony/proxies.js

Issue 7321004: Implement Object.keys for proxies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adressing Mads comments. Created 9 years, 5 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/v8natives.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/proxies.js
diff --git a/test/mjsunit/harmony/proxies.js b/test/mjsunit/harmony/proxies.js
index 490877c05fa03ab74bd088950cd7c6727f842eb8..4d27c8e604887e1a83fc7126b14541307c5927ec 100644
--- a/test/mjsunit/harmony/proxies.js
+++ b/test/mjsunit/harmony/proxies.js
@@ -309,7 +309,7 @@ TestPrototype()
-// Property names (Object.getOwnPropertyNames).
+// Property names (Object.getOwnPropertyNames, Object.keys).
function TestPropertyNames(names, handler) {
var p = Proxy.create(handler)
@@ -331,3 +331,51 @@ TestPropertyNames(["[object Object]"], {
return function() { return [{}] }
}
})
+
+
+function TestKeys(names, handler) {
+ var p = Proxy.create(handler)
+ assertArrayEquals(names, Object.keys(p))
+}
+
+TestKeys([], {
+ keys: function() { return [] }
+})
+TestKeys(["a", "zz", " ", "0"], {
+ keys: function() { return ["a", "zz", " ", 0] }
+})
+TestKeys(["throw", "function "], {
+ keys: function() { return this.keys2() },
+ keys2: function() { return ["throw", "function "] }
+})
+TestKeys(["[object Object]"], {
+ get keys() {
+ return function() { return [{}] }
+ }
+})
+TestKeys(["a", "0"], {
+ getOwnPropertyNames: function() { return ["a", 23, "zz", "", 0] },
+ getOwnPropertyDescriptor: function(k) { return {enumerable: k.length == 1} }
+})
+TestKeys(["23", "zz", ""], {
+ getOwnPropertyNames: function() { return this.getOwnPropertyNames2() },
+ getOwnPropertyNames2: function() { return ["a", 23, "zz", "", 0] },
+ getOwnPropertyDescriptor: function(k) {
+ return this.getOwnPropertyDescriptor2(k)
+ },
+ getOwnPropertyDescriptor2: function(k) { return {enumerable: k.length != 1} }
+})
+TestKeys(["a", "b", "c", "5"], {
+ get getOwnPropertyNames() {
+ return function() { return ["0", 4, "a", "b", "c", 5] }
+ },
+ get getOwnPropertyDescriptor() {
+ return function(k) { return {enumerable: k >= "44"} }
+ }
+})
+TestKeys([], {
+ get getOwnPropertyNames() {
+ return function() { return ["a", "b", "c"] }
+ },
+ getOwnPropertyDescriptor: function(k) { return {} }
+})
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698