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

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

Issue 1392203002: [es6] Support optional "receiver" argument in Reflect.get. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Be strict again. Created 5 years, 2 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/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/reflect.js
diff --git a/test/mjsunit/harmony/reflect.js b/test/mjsunit/harmony/reflect.js
index d9cd51f649d6d8c8f75b723658ade0f4f304de11..fc52c93d197c598978064b710f1e57648a44c691 100644
--- a/test/mjsunit/harmony/reflect.js
+++ b/test/mjsunit/harmony/reflect.js
@@ -53,6 +53,10 @@ function prepare(tgt) {
tgt[sym] = "foo";
tgt["noconf"] = 43;
Object.defineProperty(tgt, "noconf", {configurable: false});
+ Object.defineProperty(tgt, "getter",
+ { get: function () {return this.bla}, configurable: true });
+ Object.defineProperty(tgt, "setter",
+ { set: function () {}, configurable: true });
}
@@ -83,14 +87,43 @@ function prepare(tgt) {
(function testReflectGetOnObject() {
+ var receiver = {bla: false};
for (let tgt of objects) {
prepare(tgt);
assertEquals(true, Reflect.get(tgt, "bla"));
+ assertEquals(true, Reflect.get(tgt, "bla", tgt));
+ assertEquals(true, Reflect.get(tgt, "bla", receiver));
assertEquals(42, Reflect.get(tgt, 4));
+ assertEquals(42, Reflect.get(tgt, 4, tgt));
+ assertEquals(42, Reflect.get(tgt, 4, receiver));
assertEquals(42, Reflect.get(tgt, "4"));
+ assertEquals(42, Reflect.get(tgt, "4", tgt));
+ assertEquals(42, Reflect.get(tgt, "4", receiver));
assertEquals("foo", Reflect.get(tgt, sym));
- assertEquals(undefined, Reflect.get(tgt, "doesnotexist"));
+ assertEquals("foo", Reflect.get(tgt, sym, tgt));
+ assertEquals("foo", Reflect.get(tgt, sym, receiver));
+ assertEquals(43, Reflect.get(tgt, "noconf"));
+ assertEquals(43, Reflect.get(tgt, "noconf", tgt));
+ assertEquals(43, Reflect.get(tgt, "noconf", receiver));
+ assertEquals(true, Reflect.get(tgt, "getter"));
+ assertEquals(true, Reflect.get(tgt, "getter", tgt));
+ assertEquals(false, Reflect.get(tgt, "getter", receiver));
+ assertEquals(undefined, Reflect.get(tgt, "setter"));
+ assertEquals(undefined, Reflect.get(tgt, "setter", tgt));
+ assertEquals(undefined, Reflect.get(tgt, "setter", receiver));
+ assertEquals(undefined, Reflect.get(tgt, "foo"));
+ assertEquals(undefined, Reflect.get(tgt, "foo", tgt));
+ assertEquals(undefined, Reflect.get(tgt, "foo", receiver));
assertEquals(undefined, Reflect.get(tgt, 666));
+ assertEquals(undefined, Reflect.get(tgt, 666, tgt));
+ assertEquals(undefined, Reflect.get(tgt, 666, receiver));
+
+ let proto = tgt.__proto__;
+ tgt.__proto__ = { get foo() {return this.bla} };
+ assertEquals(true, Reflect.get(tgt, "foo"));
+ assertEquals(true, Reflect.get(tgt, "foo", tgt));
+ assertEquals(false, Reflect.get(tgt, "foo", receiver));
+ tgt.__proto__ = proto;
}
})();
@@ -128,8 +161,16 @@ function prepare(tgt) {
assertTrue(Reflect.has(tgt, 4));
assertTrue(Reflect.has(tgt, "4"));
assertTrue(Reflect.has(tgt, sym));
- assertFalse(Reflect.has(tgt, "doesnotexist"));
+ assertTrue(Reflect.has(tgt, "noconf"));
+ assertTrue(Reflect.has(tgt, "getter"));
+ assertTrue(Reflect.has(tgt, "setter"));
+ assertFalse(Reflect.has(tgt, "foo"));
assertFalse(Reflect.has(tgt, 666));
+
+ let proto = tgt.__proto__;
+ tgt.__proto__ = { get foo() {return this.bla} };
+ assertEquals(true, Reflect.has(tgt, "foo"));
+ tgt.__proto__ = proto;
}
})();
@@ -173,10 +214,17 @@ function prepare(tgt) {
}
assertTrue(Reflect.deleteProperty(tgt, sym));
assertEquals(undefined, Object.getOwnPropertyDescriptor(tgt, sym));
- assertTrue(Reflect.deleteProperty(tgt, "doesnotexist"));
- assertTrue(Reflect.deleteProperty(tgt, 666));
assertFalse(Reflect.deleteProperty(tgt, "noconf"));
assertEquals(43, tgt.noconf);
+ assertTrue(Reflect.deleteProperty(tgt, "getter"));
+ assertTrue(Reflect.deleteProperty(tgt, "setter"));
+ assertTrue(Reflect.deleteProperty(tgt, "foo"));
+ assertTrue(Reflect.deleteProperty(tgt, 666));
+
+ let proto = tgt.__proto__;
+ tgt.__proto__ = { get foo() {return this.bla} };
+ assertEquals(true, Reflect.deleteProperty(tgt, "foo"));
+ tgt.__proto__ = proto;
}
})();
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698