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

Unified Diff: test/mjsunit/harmony/array-from.js

Issue 1181623003: In Array.of and Array.from, fall back to DefineOwnProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix property attributes Created 5 years, 6 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/prologue.js ('k') | test/mjsunit/harmony/array-of.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/array-from.js
diff --git a/test/mjsunit/harmony/array-from.js b/test/mjsunit/harmony/array-from.js
index c294786c46d3ef458edef53d68dececab22fc542..d69dfe24af44853166c9fd049052ca9c1d4c3502 100644
--- a/test/mjsunit/harmony/array-from.js
+++ b/test/mjsunit/harmony/array-from.js
@@ -148,4 +148,37 @@ testArrayFrom(Math.cos, Array);
testArrayFrom(Math.cos.bind(Math), Array);
testArrayFrom(boundFn, boundFn);
+// Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a
+// setter isn't called, and a failed [[DefineOwnProperty]] will throw.
+var setterCalled = 0;
+function exotic() {
+ Object.defineProperty(this, '0', {
+ get: function() { return 2; },
+ set: function() { setterCalled++; }
+ });
+}
+// Check that exotic was defined right
arv (Not doing code reviews) 2015/06/11 16:41:30 I would remove this (line 160-165). We have plent
Dan Ehrenberg 2015/06/11 17:25:44 Done.
+var instance = new exotic();
+assertEquals(2, instance[0]);
+instance[0] = 1;
+assertEquals(2, instance[0]);
+assertEquals(1, setterCalled);
+// Accessor properties can't be overwritten with DefineOwnProperty
arv (Not doing code reviews) 2015/06/11 16:41:31 This comment is wrong. The reason why is because y
Dan Ehrenberg 2015/06/11 17:25:44 Done.
+assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError);
+assertEquals(1, setterCalled);
+
+// Check that array properties defined are writable, enumerable, configurable
+function ordinary() { }
+var x = Array.from.call(ordinary, [2]);
+var xlength = Object.getOwnPropertyDescriptor(x, 'length');
+assertEquals(1, xlength.value);
+assertEquals(true, xlength.writable);
+assertEquals(true, xlength.enumerable);
+assertEquals(true, xlength.configurable);
+var x0 = Object.getOwnPropertyDescriptor(x, 0);
+assertEquals(2, x0.value);
+assertEquals(true, xlength.writable);
+assertEquals(true, xlength.enumerable);
+assertEquals(true, xlength.configurable);
+
})();
« no previous file with comments | « src/prologue.js ('k') | test/mjsunit/harmony/array-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698