Debian Codegraph @

js/src/tests/test262/language/statements/for-of/uint8clampedarray-mutate.js

raw
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: Uint8ClampedArray mutation during traversal using for..of
6 info: |
7 Uint8ClampedArray instances should be able to be traversed using a
8 `for..of` loop, and dynamic changes to their contents should be reflected
9 in the iterated values.
10 features: [TypedArray]
11 ---*/
12
13 var iterationCount = 0;
14 var array = new Uint8ClampedArray([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);
35
36 reportCompare(0, 0);