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..839fae26b6b476468d32571fa416fc198d3d8963 100644 |
--- a/test/mjsunit/harmony/array-from.js |
+++ b/test/mjsunit/harmony/array-from.js |
@@ -148,4 +148,23 @@ 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 |
+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 |
+assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError); |
+assertEquals(1, setterCalled); |
+ |
})(); |
arv (Not doing code reviews)
2015/06/11 13:04:01
I see that there is already a test for accessors o
Dan Ehrenberg
2015/06/11 16:27:25
Not sure what you're referring to, but I added a t
arv (Not doing code reviews)
2015/06/11 16:41:30
Ignore me.
|