| 1 | // Copyright 2015 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 | load("testsrc/assert.js"); |
| 6 | |
| 7 | (function TestForOfName() { |
| 8 | var result = 0; |
| 9 | var index; |
| 10 | |
| 11 | for (index of [1, 2, 3, 4, 5]) result += index; |
| 12 | |
| 13 | assertEquals(result, 15); |
| 14 | assertEquals(index, 5); |
| 15 | })(); |
| 16 | |
| 17 | |
| 18 | (function TestForOfProperty() { |
| 19 | var O = {}; |
| 20 | var result = 0; |
| 21 | |
| 22 | for (O.index of [1, 2, 3, 4, 5]) result += O.index; |
| 23 | |
| 24 | assertEquals(result, 15); |
| 25 | assertEquals(O.index, 5); |
| 26 | })(); |
| 27 | |
| 28 | "success"; |