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

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

Issue 1421033002: [es6] Partially implement Reflect.defineProperty. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address a comment and rebase. 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.cc ('k') | test/mjsunit/harmony/reflect-define-property.js » ('j') | 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 73d0115db916f3d7041ae3333d7dc9f059e09220..c410cf903258cec7b8fd529f3cdf46b6fb7e790a 100644
--- a/test/mjsunit/harmony/reflect.js
+++ b/test/mjsunit/harmony/reflect.js
@@ -177,6 +177,41 @@ function prepare(tgt) {
////////////////////////////////////////////////////////////////////////////////
+// Reflect.defineProperty
+
+
+(function testReflectDefinePropertyArity() {
+ assertEquals(3, Reflect.defineProperty.length);
+})();
+
+
+(function testReflectDefinePropertyOnNonObject() {
+ assertThrows(function() { Reflect.defineProperty(); }, TypeError);
+ assertThrows(function() { Reflect.defineProperty(42, "bla"); }, TypeError);
+ assertThrows(function() { Reflect.defineProperty(null, "bla"); }, TypeError);
+ assertThrows(function() { Reflect.defineProperty({}, "bla"); }, TypeError);
+ assertThrows(function() { Reflect.defineProperty({}, "bla", 42); },
+ TypeError);
+ assertThrows(function() { Reflect.defineProperty({}, "bla", null); },
+ TypeError);
+})();
+
+
+(function testReflectDefinePropertyKeyConversion() {
+ var tgt = {};
+ var a = { [Symbol.toPrimitive]: function() { return "bla" } };
+ var b = { [Symbol.toPrimitive]: function() { throw "gaga" } };
+ assertTrue(Reflect.defineProperty(tgt, a, {value: 42}));
+ assertEquals(tgt.bla, 42);
+ assertThrows(function() { Reflect.defineProperty(tgt, b); }, "gaga");
+})();
+
+
+// See reflect-define-property.js for further tests.
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// Reflect.deleteProperty
@@ -261,12 +296,12 @@ function prepare(tgt) {
(function testReflectSetPrototypeOfOnNonObject() {
assertThrows(function() { Reflect.setPrototypeOf(undefined, {}); },
- TypeError);
+ TypeError);
assertThrows(function() { Reflect.setPrototypeOf(42, {}); }, TypeError);
assertThrows(function() { Reflect.setPrototypeOf(null, {}); }, TypeError);
assertThrows(function() { Reflect.setPrototypeOf({}, undefined); },
- TypeError);
+ TypeError);
assertThrows(function() { Reflect.setPrototypeOf({}, 42); }, TypeError);
assertTrue(Reflect.setPrototypeOf({}, null));
})();
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/reflect-define-property.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698