| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-arrays | 5 // Flags: --harmony-arrays |
| 6 (function() { | 6 (function() { |
| 7 | 7 |
| 8 assertEquals(1, Array.from.length); | 8 assertEquals(1, Array.from.length); |
| 9 | 9 |
| 10 function assertArrayLikeEquals(value, expected, type) { | 10 function assertArrayLikeEquals(value, expected, type) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 testArrayFrom(Array, Array); | 142 testArrayFrom(Array, Array); |
| 143 testArrayFrom(null, Array); | 143 testArrayFrom(null, Array); |
| 144 testArrayFrom({}, Array); | 144 testArrayFrom({}, Array); |
| 145 testArrayFrom(Object, Object); | 145 testArrayFrom(Object, Object); |
| 146 testArrayFrom(Other, Other); | 146 testArrayFrom(Other, Other); |
| 147 testArrayFrom(Math.cos, Array); | 147 testArrayFrom(Math.cos, Array); |
| 148 testArrayFrom(Math.cos.bind(Math), Array); | 148 testArrayFrom(Math.cos.bind(Math), Array); |
| 149 testArrayFrom(boundFn, boundFn); | 149 testArrayFrom(boundFn, boundFn); |
| 150 | 150 |
| 151 // Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a |
| 152 // setter isn't called, and a failed [[DefineOwnProperty]] will throw. |
| 153 var setterCalled = 0; |
| 154 function exotic() { |
| 155 Object.defineProperty(this, '0', { |
| 156 get: function() { return 2; }, |
| 157 set: function() { setterCalled++; } |
| 158 }); |
| 159 } |
| 160 // Non-configurable properties can't be overwritten with DefineOwnProperty |
| 161 assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError); |
| 162 // The setter wasn't called |
| 163 assertEquals(0, setterCalled); |
| 164 |
| 165 // Check that array properties defined are writable, enumerable, configurable |
| 166 function ordinary() { } |
| 167 var x = Array.from.call(ordinary, [2]); |
| 168 var xlength = Object.getOwnPropertyDescriptor(x, 'length'); |
| 169 assertEquals(1, xlength.value); |
| 170 assertEquals(true, xlength.writable); |
| 171 assertEquals(true, xlength.enumerable); |
| 172 assertEquals(true, xlength.configurable); |
| 173 var x0 = Object.getOwnPropertyDescriptor(x, 0); |
| 174 assertEquals(2, x0.value); |
| 175 assertEquals(true, xlength.writable); |
| 176 assertEquals(true, xlength.enumerable); |
| 177 assertEquals(true, xlength.configurable); |
| 178 |
| 151 })(); | 179 })(); |
| OLD | NEW |