Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Ensure that mutation of the Object.keys result doesn't affect the | |
| 6 // enumeration cache for fast-mode objects. | |
| 7 (function() { | |
| 8 const a = {x:1, y:2}; | |
| 9 let k = Object.keys(a); | |
|
Camillo Bruni
2017/05/03 08:40:44
You could additionally do: %VerifyHeapObject(k)
Benedikt Meurer
2017/05/17 05:09:19
Done.
| |
| 10 assertEquals(2, k.length); | |
| 11 assertEquals("x", k[0]); | |
| 12 assertEquals("y", k[1]); | |
| 13 k[0] = "y"; | |
| 14 k[1] = "x"; | |
| 15 k = Object.keys(a); | |
| 16 assertEquals(2, k.length); | |
| 17 assertEquals("x", k[0]); | |
| 18 assertEquals("y", k[1]); | |
| 19 })(); | |
| 20 | |
| 21 // Ensure that the copy-on-write keys are handled properly, even in | |
| 22 // the presence of Symbols. | |
| 23 (function() { | |
| 24 const s = Symbol(); | |
| 25 const a = {[s]: 1}; | |
| 26 let k = Object.keys(a); | |
| 27 assertEquals(0, k.length); | |
| 28 k.shift(); | |
| 29 assertEquals(0, k.length); | |
| 30 })(); | |
| OLD | NEW |