Index: test/mjsunit/harmony/array-of.js |
diff --git a/test/mjsunit/harmony/array-of.js b/test/mjsunit/harmony/array-of.js |
index adf7cb547cdae9eebd9fdec14f01c8d562526e65..9164b21efec8fe393de83ce1a3ec61ba9084602e 100644 |
--- a/test/mjsunit/harmony/array-of.js |
+++ b/test/mjsunit/harmony/array-of.js |
@@ -182,3 +182,38 @@ assertThrows(function() { new Array.of() }, TypeError); // not a constructor |
assertEquals(instance instanceof boundFn, true); |
assertEquals(Array.isArray(instance), false); |
})(); |
+ |
+(function testDefinesOwnProperty() { |
+ // 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.of.call(exotic, 1); }, TypeError); |
+ assertEquals(1, setterCalled); |
+ |
+ // Check that array properties defined are writable, enumerable, configurable |
+ function ordinary() { } |
+ var x = Array.of.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); |
+})(); |