keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 1 | // Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | /*--- |
| 4 | es6id: 13.6.4 |
| 5 | description: Int8Array mutation during traversal using for..of |
| 6 | info: > |
| 7 | Int8Array instances should be able to be traversed using a `for..of` loop, |
| 8 | and dynamic changes to their contents should be reflected in the iterated |
| 9 | values. |
| 10 | features: [TypedArray] |
| 11 | ---*/ |
| 12 | |
| 13 | var iterationCount = 0; |
| 14 | var array = new Int8Array([3, 2, 4, 1]); |
| 15 | |
| 16 | var first = 3; |
| 17 | var second = 64; |
| 18 | var third = 4; |
| 19 | var fourth = 1; |
| 20 | |
| 21 | for (var x of array) { |
| 22 | assert.sameValue(x, first); |
| 23 | |
| 24 | first = second; |
| 25 | second = third; |
| 26 | third = fourth; |
| 27 | fourth = null; |
| 28 | |
| 29 | array[1] = 64; |
| 30 | |
| 31 | iterationCount += 1; |
| 32 | } |
| 33 | |
| 34 | assert.sameValue(iterationCount, 4); |