Add tests for `for..of` iteration over built-ins

This commit is contained in:
Mike Pennisi 2015-05-27 18:39:03 -04:00
parent 42d16da901
commit a321e87a2d
36 changed files with 1120 additions and 0 deletions

View File

@ -0,0 +1,33 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Array entry removal and re-insertion during traversal using for..of
info: >
Entries removed from an Array instance during traversal should be visited
if they are re-inserted prior to iterator exhaustion.
es6id: 13.6.4
---*/
var array = [0, 1];
var iterationCount = 0;
var first = 0;
var second = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = null;
if (first !== null) {
array.pop();
array.push(1);
}
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Array entry removal during traversal using for..of
info:
Entries removed from an Array instance during traversal should not be
visited.
es6id: 13.6.4
---*/
var array = [0, 1];
var iterationCount = 0;
for (var x of array) {
assert.sameValue(x, 0);
array.pop();
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Array entry insertion and removal items during traversal using for..of
info: >
New entries inserted into an Array instance during traversal should not be
visited if they are removed prior to visitation.
es6id: 13.6.4
---*/
var array = [0];
var iterationCount = 0;
for (var x of array) {
assert.sameValue(x, 0);
array.push(1);
array.pop();
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Array entry insertion during traversal using for..of
info: >
New entries inserted into an Array instance during traversal should be
visited.
es6id: 13.6.4
---*/
var array = [0];
var iterationCount = 0;
var first = 0;
var second = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = null;
if (first !== null) {
array.push(1);
}
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Error in Array entry access during traversal using for..of
info: >
If retrieving an element from the array produces an error, that error
should be forwarded to the run time.
es6id: 13.6.4
---*/
var array = [];
var iterationCount = 0;
Object.defineProperty(array, '0', {
get: function() {
throw new Test262Error();
}
});
assert.throws(Test262Error, function() {
for (var value of array) {
iterationCount += 1;
}
});
assert.sameValue(iterationCount, 0, 'The loop body is not evaluated');

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Float32Array mutation during traversal using for..of
info: >
Float32Array instances should be able to be traversed using a `for..of`
loop, and dynamic changes to their contents should be reflected in the
iterated values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Float32Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,31 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Float32Array traversal using for..of
info: >
Float32Array instances should be able to be traversed using a `for..of`
loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Float32Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Float64Array mutation during traversal using for..of
info: >
Float64Array instances should be able to be traversed using a `for..of`
loop, and dynamic changes to their contents should be reflected in the
iterated values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Float64Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,31 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Float64Array traversal using for..of
info: >
Float64Array instances should be able to be traversed using a `for..of`
loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Float64Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Int16Array mutation during traversal using for..of
info: >
Int16Array instances should be able to be traversed using a `for..of` loop,
and dynamic changes to their contents should be reflected in the iterated
values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int16Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,29 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: >
Int16Array instances should be able to be traversed using a `for..of` loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int16Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Int32Array mutation during traversal using for..of
info: >
Int32Array instances should be able to be traversed using a `for..of` loop,
and dynamic changes to their contents should be reflected in the iterated
values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int32Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,29 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: >
Int32Array instances should be able to be traversed using a `for..of` loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int32Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Int8Array mutation during traversal using for..of
info: >
Int8Array instances should be able to be traversed using a `for..of` loop,
and dynamic changes to their contents should be reflected in the iterated
values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int8Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,29 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: >
Int8Array instances should be able to be traversed using a `for..of` loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Int8Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Map entry removal and re-insertion during traversal using for..of
info: >
Entries removed from a Map instance during traversal should be visited if
they are re-inserted prior to iterator exhaustion.
es6id: 13.6.4
features: [Map]
---*/
var map = new Map();
var iterationCount = 0;
var first = [0, 'a'];
var second = [1, 'b'];
map.set(0, 'a');
map.set(1, 'b');
for (var x of map) {
assert.sameValue(x[0], first[0]);
assert.sameValue(x[1], first[1]);
first = second;
second = null;
if (first !== null) {
map.delete(1);
map.set(1, 'b');
}
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Entries removed from a Map instance during traversal should not be visited.
es6id: 13.6.4
features: [Map]
---*/
var map = new Map();
var iterationCount = 0;
map.set(0, 'a');
map.set(1, 'b');
for (var x of map) {
assert.sameValue(x[0], 0);
assert.sameValue(x[1], 'a');
map.delete(1);
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,28 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Map entry insertion during traversal using for..of
info: >
New entries inserted into a Map instance during traversal should not be
visited if they are removed prior to visitation.
es6id: 13.6.4
features: [Map]
---*/
var map = new Map();
var iterationCount = 0;
map.set(0, 'a');
for (var x of map) {
assert.sameValue(x[0], 0);
assert.sameValue(x[1], 'a');
map.set(1, 'b');
map.delete(1);
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Map entry insertion during traversal using for..of
info: >
New entries inserted into a Map instance during traversal should be
visited.
es6id: 13.6.4
features: [Map]
---*/
var map = new Map();
var iterationCount = 0;
var first = [0, 'a'];
var second = [1, 'b'];
map.set(0, 'a');
for (var x of map) {
assert.sameValue(x[0], first[0]);
assert.sameValue(x[1], first[1]);
first = second;
second = null;
map.set(1, 'b');
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,36 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Map traversal using for..of
info: >
Map instances should be able to be traversed using a `for...of` loop.
es6id: 13.6.4
features: [Map]
---*/
var map = new Map();
var obj = {};
var iterationCount = 0;
var first = [0, 'a'];
var second = [true, false];
var third = [null, undefined];
var fourth = [NaN, obj];
map.set(0, 'a');
map.set(true, false);
map.set(null, undefined);
map.set(NaN, obj);
for (var x of map) {
assert.sameValue(x[0], first[0]);
assert.sameValue(x[1], first[1]);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,36 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Set entry removal and re-insertion during traversal using for..of
info: >
Entries removed from a Set instance during traversal should be visited if
they are re-inserted prior to iterator exhaustion.
es6id: 13.6.4
features: [Set]
---*/
var set = new Set();
var iterationCount = 0;
var first = 0;
var second = 1;
set.add(0);
set.add(1);
for (var x of set) {
assert.sameValue(x, first);
first = second;
second = null;
if (first !== null) {
set.delete(1);
set.add(1);
}
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Entries removed from a Set instance during traversal should not be visited.
es6id: 13.6.4
features: [Set]
---*/
var set = new Set();
var iterationCount = 0;
set.add(0);
set.add(1);
for (var x of set) {
assert.sameValue(x, 0);
set.delete(1);
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Set entry insertion and removal during traversal using for..of
info: >
New entries inserted into a Set instance during traversal should not be
visited if they are removed prior to visitation.
es6id: 13.6.4
features: [Set]
---*/
var set = new Set();
var iterationCount = 0;
set.add(0);
for (var x of set) {
assert.sameValue(x, 0);
set.add(1);
set.delete(1);
iterationCount += 1;
}
assert.sameValue(iterationCount, 1);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Set entry insertaion during traversal using for..of
info: >
New entries inserted into a Set instance during traversal should be
visited.
es6id: 13.6.4
features: [Set]
---*/
var set = new Set();
var iterationCount = 0;
var first = 0;
var second = 1;
set.add(0);
for (var x of set) {
assert.sameValue(x, first);
first = second;
second = null;
set.add(1);
iterationCount += 1;
}
assert.sameValue(iterationCount, 2);

View File

@ -0,0 +1,46 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Set instances should be able to be traversed using a `for...of` loop.
es6id: 13.6.4
features: [Set]
---*/
var set = new Set();
var obj = {};
var iterationCount = 0;
var first = 0;
var second = 'a';
var third = true;
var fourth = false;
var fifth = null;
var sixth = undefined;
var seventh = NaN;
var eight = obj;
set.add(0);
set.add('a');
set.add(true);
set.add(false);
set.add(null);
set.add(undefined);
set.add(NaN);
set.add(obj);
for (var x of set) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = fifth;
fifth = sixth;
sixth = seventh;
seventh = eight;
eight = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 8);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: String traversal using for..of (incomplete surrogate pairs)
info: >
String literals should be able to be traversed using a `for...of` loop. The
loop body should execute once for each incomplete surrogate pair.
es6id: 13.6.4
---*/
var string = 'a\ud801b\ud801';
var first = 'a';
var second = '\ud801';
var third = 'b';
var fourth = '\ud801';
var iterationCount = 0;
for (var value of string) {
assert.sameValue(value, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: String traversal using for..of (astral symbols)
info: >
String literals should be able to be traversed using a `for...of` loop. The
loop body should execute once for each astral symbol.
es6id: 13.6.4
---*/
var string = 'a\ud801\udc28b\ud801\udc28';
var first = 'a';
var second = '𐐨';
var third = 'b';
var fourth = '𐐨';
var iterationCount = 0;
for (var value of string) {
assert.sameValue(value, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: String traversal using for..of
info: >
String literals should be able to be traversed using a `for...of` loop. The
loop body should execute once for every BMP character.
es6id: 13.6.4
---*/
var string = 'abc';
var first = 'a';
var second = 'b';
var third = 'c';
var iterationCount = 0;
for (var value of string) {
assert.sameValue(value, first);
first = second;
second = third;
third = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 3);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint16Array mutation during traversal using for..of
info: >
Uint16Array instances should be able to be traversed using a `for..of`
loop, and dynamic changes to their contents should be reflected in the
iterated values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint16Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,31 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint16Array traversal using for..of
info: >
Uint16Array instances should be able to be traversed using a `for..of`
loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint16Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint32Array mutation during traversal using for..of
info: >
Uint32Array instances should be able to be traversed using a `for..of`
loop, and dynamic changes to their contents should be reflected in the
iterated values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint32Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,31 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint32Array traversal using for..of
info: >
Uint32Array instances should be able to be traversed using a `for..of`
loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint32Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint8Array mutation during traversal using for..of
info: >
Uint8Array instances should be able to be traversed using a `for..of` loop,
and dynamic changes to their contents should be reflected in the iterated
values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint8Array([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,29 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: >
Uint8Array instances should be able to be traversed using a `for..of` loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint8Array([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,34 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: Uint8ClampedArray mutation during traversal using for..of
info: >
Uint8ClampedArray instances should be able to be traversed using a
`for..of` loop, and dynamic changes to their contents should be reflected
in the iterated values.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint8ClampedArray([3, 2, 4, 1]);
var first = 3;
var second = 64;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
array[1] = 64;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);

View File

@ -0,0 +1,30 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4
description: >
Uint8ClampedArray instances should be able to be traversed using a
`for..of` loop.
features: [TypedArray]
---*/
var iterationCount = 0;
var array = new Uint8ClampedArray([3, 2, 4, 1]);
var first = 3;
var second = 2;
var third = 4;
var fourth = 1;
for (var x of array) {
assert.sameValue(x, first);
first = second;
second = third;
third = fourth;
fourth = null;
iterationCount += 1;
}
assert.sameValue(iterationCount, 4);