mirror of
https://github.com/tc39/test262.git
synced 2025-06-18 04:50:30 +02:00
Import tests from Google V8 (native iterators)
These tests are derived from the following files within the Google V8 project: test/mjsunit/es6/typed-array-iterator.js test/mjsunit/es6/arguments-iterator.js test/mjsunit/es6/string-iterator.js test/mjsunit/es6/collection-iterator.js
This commit is contained in:
parent
8af82000ed
commit
e8cc40a0a8
@ -6,8 +6,8 @@
|
|||||||
When an item is added to the array after the iterator is created but
|
When an item is added to the array after the iterator is created but
|
||||||
before the iterator is "done" (as defined by 22.1.5.2.1), the new item
|
before the iterator is "done" (as defined by 22.1.5.2.1), the new item
|
||||||
should be accessible via iteration. When an item is added to the array
|
should be accessible via iteration. When an item is added to the array
|
||||||
after the iterator is is "done", the new item should not be accessible
|
after the iterator is "done", the new item should not be accessible via
|
||||||
via iteration.
|
iteration.
|
||||||
es6id: 22.1.3.30
|
es6id: 22.1.3.30
|
||||||
---*/
|
---*/
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
When an item is added to the array after the iterator is created but
|
When an item is added to the array after the iterator is created but
|
||||||
before the iterator is "done" (as defined by 22.1.5.2.1), the new item's
|
before the iterator is "done" (as defined by 22.1.5.2.1), the new item's
|
||||||
key should be accessible via iteration. When an item is added to the
|
key should be accessible via iteration. When an item is added to the
|
||||||
array after the iterator is is "done", the new item's key should not be
|
array after the iterator is "done", the new item's key should not be
|
||||||
accessible via iteration.
|
accessible via iteration.
|
||||||
es6id: 22.1.3.13
|
es6id: 22.1.3.13
|
||||||
---*/
|
---*/
|
||||||
|
35
test/built-ins/Float32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Float32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Float32Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Float64Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Float64Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Float64Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Int16Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Int16Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Int16Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Int32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Int32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Int32Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Int8Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Int8Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Int8Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
18
test/built-ins/Map/prototype/Symbol.iterator-Symbol.toStringTag-property-descriptor.js
vendored
Normal file
18
test/built-ins/Map/prototype/Symbol.iterator-Symbol.toStringTag-property-descriptor.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
`Object.prototype.getOwnPropertyDescriptor` should reflect the value and
|
||||||
|
writability of the @@toStringTag attribute.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
es6id: 23.1.3.13
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var MapIteratorProto = Object.getPrototypeOf(new Map()[Symbol.iterator]());
|
||||||
|
|
||||||
|
assert.sameValue('Map Iterator', MapIteratorProto[Symbol.toStringTag]);
|
||||||
|
|
||||||
|
verifyNotEnumerable(MapIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyNotWritable(MapIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyConfigurable(MapIteratorProto, Symbol.toStringTag);
|
52
test/built-ins/Map/prototype/Symbol.iterator-next-iteration-mutable.js
vendored
Normal file
52
test/built-ins/Map/prototype/Symbol.iterator-next-iteration-mutable.js
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
When an item is added to the map after the iterator is created but before
|
||||||
|
the iterator is "done" (as defined by 23.1.5.2.1), the new item should be
|
||||||
|
accessible via iteration. When an item is added to the map after the
|
||||||
|
iterator is "done", the new item should not be accessible via iteration.
|
||||||
|
es6id: 23.1.3.12
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
|
||||||
|
var iterator = map[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 1, 'First result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 11, 'First result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 2, 'Second result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 22, 'Second result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 3, 'Third result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 33, 'Third result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
map.set(4, 44);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
47
test/built-ins/Map/prototype/Symbol.iterator-next-iteration.js
vendored
Normal file
47
test/built-ins/Map/prototype/Symbol.iterator-next-iteration.js
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.2.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
var iterator = map[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 1, 'First result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 11, 'First result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 2, 'Second result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 22, 'Second result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 3, 'Third result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 33, 'Third result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
15
test/built-ins/Map/prototype/Symbol.iterator-next-no-map-data.js
vendored
Normal file
15
test/built-ins/Map/prototype/Symbol.iterator-next-no-map-data.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[MapData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.1.5.1.
|
||||||
|
es6id: 23.1.3.12
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterator = new Map()[Symbol.iterator]();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
14
test/built-ins/Map/prototype/Symbol.iterator-property-descriptor.js
vendored
Normal file
14
test/built-ins/Map/prototype/Symbol.iterator-property-descriptor.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should exist on the Map prototype, and it should be writable
|
||||||
|
and configurable, but not enumerable.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
es6id: 23.1.3.12
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, Symbol.iterator);
|
||||||
|
verifyWritable(Map.prototype, Symbol.iterator);
|
||||||
|
verifyConfigurable(Map.prototype, Symbol.iterator);
|
47
test/built-ins/Map/prototype/entries-iteration.js
vendored
Normal file
47
test/built-ins/Map/prototype/entries-iteration.js
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.1.3.4
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
var iterator = map.entries();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 1, 'First result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 11, 'First result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 2, 'Second result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 22, 'Second result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 3, 'Third result `value` (map key)');
|
||||||
|
assert.sameValue(result.value[1], 33, 'Third result `value` (map value)');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
13
test/built-ins/Map/prototype/entries-no-map-data.js
vendored
Normal file
13
test/built-ins/Map/prototype/entries-no-map-data.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[MapData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.1.5.1.
|
||||||
|
es6id: 23.1.3.4
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call({});
|
||||||
|
});
|
41
test/built-ins/Map/prototype/keys-iteration.js
vendored
Normal file
41
test/built-ins/Map/prototype/keys-iteration.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.1.3.8
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
var iterator = map.keys();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
13
test/built-ins/Map/prototype/keys-no-map-data.js
vendored
Normal file
13
test/built-ins/Map/prototype/keys-no-map-data.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[MapData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.1.5.1.
|
||||||
|
es6id: 23.1.3.8
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.keys.call({});
|
||||||
|
});
|
46
test/built-ins/Map/prototype/values-iteration-mutable.js
vendored
Normal file
46
test/built-ins/Map/prototype/values-iteration-mutable.js
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
When an item is added to the map after the iterator is created but before
|
||||||
|
the iterator is "done" (as defined by 23.1.5.2.1), the new item should be
|
||||||
|
accessible via iteration. When an item is added to the map after the
|
||||||
|
iterator is "done", the new item should not be accessible via iteration.
|
||||||
|
es6id: 23.1.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
|
||||||
|
var iterator = map.values();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 11, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 22, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 33, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
map.set(4, 44);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
41
test/built-ins/Map/prototype/values-iteration.js
vendored
Normal file
41
test/built-ins/Map/prototype/values-iteration.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.1.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(1, 11);
|
||||||
|
map.set(2, 22);
|
||||||
|
map.set(3, 33);
|
||||||
|
|
||||||
|
var iterator = map.values();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 11, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 22, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 33, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
13
test/built-ins/Map/prototype/values-no-map-data.js
vendored
Normal file
13
test/built-ins/Map/prototype/values-no-map-data.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[MapData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.1.5.1.
|
||||||
|
es6id: 23.1.3.4
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.values.call({});
|
||||||
|
});
|
18
test/built-ins/Set/prototype/Symbol.iterator-Symbol.toStringTag-property-descriptor.js
vendored
Normal file
18
test/built-ins/Set/prototype/Symbol.iterator-Symbol.toStringTag-property-descriptor.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
`Object.prototype.getOwnPropertyDescriptor` should reflect the value and
|
||||||
|
writability of the @@toStringTag attribute.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
es6id: 23.2.3.12
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var SetIteratorProto = Object.getPrototypeOf(new Set()[Symbol.iterator]());
|
||||||
|
|
||||||
|
assert.sameValue('Set Iterator', SetIteratorProto[Symbol.toStringTag]);
|
||||||
|
|
||||||
|
verifyNotEnumerable(SetIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyNotWritable(SetIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyConfigurable(SetIteratorProto, Symbol.toStringTag);
|
46
test/built-ins/Set/prototype/Symbol.iterator-next-iteration-mutable.js
vendored
Normal file
46
test/built-ins/Set/prototype/Symbol.iterator-next-iteration-mutable.js
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
When an item is added to the set after the iterator is created but before
|
||||||
|
the iterator is "done" (as defined by 23.2.5.2.1), the new item should be
|
||||||
|
accessible via iteration. When an item is added to the set after the
|
||||||
|
iterator is "done", the new item should not be accessible via iteration.
|
||||||
|
es6id: 23.2.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = new Set();
|
||||||
|
set.add(1);
|
||||||
|
set.add(2);
|
||||||
|
|
||||||
|
var iterator = set[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
set.add(3);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
set.add(4);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
41
test/built-ins/Set/prototype/Symbol.iterator-next-iteration.js
vendored
Normal file
41
test/built-ins/Set/prototype/Symbol.iterator-next-iteration.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.2.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = new Set();
|
||||||
|
set.add(1);
|
||||||
|
set.add(2);
|
||||||
|
set.add(3);
|
||||||
|
|
||||||
|
var iterator = set[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
15
test/built-ins/Set/prototype/Symbol.iterator-next-no-set-data.js
vendored
Normal file
15
test/built-ins/Set/prototype/Symbol.iterator-next-no-set-data.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[SetData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.2.5.1.
|
||||||
|
es6id: 23.2.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterator = new Set()[Symbol.iterator]();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
iterator.next.call({});
|
||||||
|
});
|
14
test/built-ins/Set/prototype/Symbol.iterator-property-descriptor.js
vendored
Normal file
14
test/built-ins/Set/prototype/Symbol.iterator-property-descriptor.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should exist on the Array prototype, and it should be writable
|
||||||
|
and configurable, but not enumerable.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
es6id: 23.2.3.11
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyNotEnumerable(Set.prototype, Symbol.iterator);
|
||||||
|
verifyWritable(Set.prototype, Symbol.iterator);
|
||||||
|
verifyConfigurable(Set.prototype, Symbol.iterator);
|
47
test/built-ins/Set/prototype/entries-iteration.js
vendored
Normal file
47
test/built-ins/Set/prototype/entries-iteration.js
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.2.3.5
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = new Set();
|
||||||
|
set.add(1);
|
||||||
|
set.add(2);
|
||||||
|
set.add(3);
|
||||||
|
|
||||||
|
var iterator = set.entries();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 1, 'First result `value` ("key")');
|
||||||
|
assert.sameValue(result.value[1], 1, 'First result `value` ("value")');
|
||||||
|
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 2, 'Second result `value` ("key")');
|
||||||
|
assert.sameValue(result.value[1], 2, 'Second result `value` ("value")');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value[0], 3, 'Third result `value` ("key")');
|
||||||
|
assert.sameValue(result.value[1], 3, 'Third result `value` ("value")');
|
||||||
|
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
13
test/built-ins/Set/prototype/entries-no-set-data.js
vendored
Normal file
13
test/built-ins/Set/prototype/entries-no-set-data.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[SetData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.2.5.1.
|
||||||
|
es6id: 23.2.3.5
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Set.prototype.entries.call({});
|
||||||
|
});
|
11
test/built-ins/Set/prototype/keys.js
vendored
Normal file
11
test/built-ins/Set/prototype/keys.js
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The initial value of the keys property is the same function object as the
|
||||||
|
initial value of the values property.
|
||||||
|
es6id: 23.2.3.8
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Set.prototype.keys, Set.prototype.values);
|
46
test/built-ins/Set/prototype/values-iteration-mutable.js
vendored
Normal file
46
test/built-ins/Set/prototype/values-iteration-mutable.js
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
When an item is added to the set after the iterator is created but before
|
||||||
|
the iterator is "done" (as defined by 23.2.5.2.1), the new item should be
|
||||||
|
accessible via iteration. When an item is added to the array after the
|
||||||
|
iterator is "done", the new item should not be accessible via iteration.
|
||||||
|
es6id: 23.2.3.10
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = new Set();
|
||||||
|
set.add(1);
|
||||||
|
set.add(2);
|
||||||
|
|
||||||
|
var iterator = set.values();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
set.add(3);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
set.add(4);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
41
test/built-ins/Set/prototype/values-iteration.js
vendored
Normal file
41
test/built-ins/Set/prototype/values-iteration.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
The method should return a valid iterator with the context as the
|
||||||
|
IteratedObject.
|
||||||
|
es6id: 23.2.3.10
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = new Set();
|
||||||
|
set.add(1);
|
||||||
|
set.add(2);
|
||||||
|
set.add(3);
|
||||||
|
|
||||||
|
var iterator = set.values();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
13
test/built-ins/Set/prototype/values-no-set-data.js
vendored
Normal file
13
test/built-ins/Set/prototype/values-no-set-data.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
If the context does not have a [[SetData]] internal slot, throw a
|
||||||
|
TypeError exception as per 23.2.5.1.
|
||||||
|
es6id: 23.2.3.10
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Set.prototype.values.call({});
|
||||||
|
});
|
18
test/built-ins/String/prototype/Symbol.iterator/Symbol.toStringTag.js
vendored
Normal file
18
test/built-ins/String/prototype/Symbol.iterator/Symbol.toStringTag.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 21.1.5.2.1
|
||||||
|
description: >
|
||||||
|
The initial value of the @@toStringTag property is the string value "String
|
||||||
|
Iterator". This property has the attributes { [[Writable]]: false,
|
||||||
|
[[Enumerable]]: false, [[Configurable]]: true }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var StringIteratorProto = Object.getPrototypeOf(''[Symbol.iterator]());
|
||||||
|
|
||||||
|
assert.sameValue(StringIteratorProto[Symbol.toStringTag], 'String Iterator');
|
||||||
|
|
||||||
|
verifyNotEnumerable(StringIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyNotWritable(StringIteratorProto, Symbol.toStringTag);
|
||||||
|
verifyConfigurable(StringIteratorProto, Symbol.toStringTag);
|
15
test/built-ins/String/prototype/Symbol.iterator/ancestry.js
vendored
Normal file
15
test/built-ins/String/prototype/Symbol.iterator/ancestry.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 21.1.5.2
|
||||||
|
description: >
|
||||||
|
The [[Prototype]] internal slot ofthe %StringIteratorPrototype% is the
|
||||||
|
%IteratorPrototype% intrinsic object (25.1.2).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var strItrProto = Object.getPrototypeOf(''[Symbol.iterator]());
|
||||||
|
var itrProto = Object.getPrototypeOf(
|
||||||
|
Object.getPrototypeOf([][Symbol.iterator]())
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Object.getPrototypeOf(strItrProto), itrProto);
|
83
test/built-ins/String/prototype/Symbol.iterator/next-iteration-surrogate-pairs.js
vendored
Normal file
83
test/built-ins/String/prototype/Symbol.iterator/next-iteration-surrogate-pairs.js
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 21.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Iteration should respect UTF-16-encoded Unicode code points specified via
|
||||||
|
surrogate pairs.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var lo = '\uD834';
|
||||||
|
var hi = '\uDF06';
|
||||||
|
var pair = lo + hi;
|
||||||
|
var string = 'a' + pair + 'b' + lo + pair + hi + lo;
|
||||||
|
var iterator = string[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 'a', 'First normal code point `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First normal code point `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, pair, 'Surrogate pair `value` (between normal code points)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, false, 'Surrogate pair `done` flag (between normal code points)'
|
||||||
|
);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 'b', 'Second normal code point `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second normal code point `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value,
|
||||||
|
lo,
|
||||||
|
'Lone lower code point `value` (following normal code point)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done,
|
||||||
|
false,
|
||||||
|
'Lone lower code point `done` flag (following normal code point)'
|
||||||
|
);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value,
|
||||||
|
pair,
|
||||||
|
'Surrogate pair `value` (between lone lower- and upper- code points)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done,
|
||||||
|
false,
|
||||||
|
'Surrogate pair `done` flag (between lone lower- and upper- code points)'
|
||||||
|
);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, hi, 'Lone upper code point `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Lone upper code point `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value,
|
||||||
|
lo,
|
||||||
|
'Lone lower code point `value` (following lone upper code point)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done,
|
||||||
|
false,
|
||||||
|
'Lone lower code point `done` flag (following lone upper code point)'
|
||||||
|
);
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request'
|
||||||
|
);
|
35
test/built-ins/String/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/String/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 21.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Iteration should visit each UTF-8 code point exactly once.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var string = "abc";
|
||||||
|
var iterator = string[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 'a', 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 'b', 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 'c', 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
15
test/built-ins/String/prototype/Symbol.iterator/next-missing-internal-slots.js
vendored
Normal file
15
test/built-ins/String/prototype/Symbol.iterator/next-missing-internal-slots.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 21.1.5.2.1 S 3
|
||||||
|
description: >
|
||||||
|
If the `this` value does not have all of the internal slots of an String
|
||||||
|
Iterator Instance (21.1.5.3), throw a `TypeError` exception.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterator = ''[Symbol.iterator]();
|
||||||
|
var object = Object.create(iterator);
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
object.next();
|
||||||
|
});
|
35
test/built-ins/Uint16Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Uint16Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Uint16Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Uint32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Uint32Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Uint32Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Uint8Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Uint8Array/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Uint8Array([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'first result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'first result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
35
test/built-ins/Uint8ClampedArray/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
35
test/built-ins/Uint8ClampedArray/prototype/Symbol.iterator/next-iteration.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 22.1.5.2.1
|
||||||
|
description: >
|
||||||
|
Visits each element of the array in order and ceases iteration once all
|
||||||
|
values have been visited.
|
||||||
|
---*/
|
||||||
|
var array = new Uint8ClampedArray([3, 1, 2]);
|
||||||
|
var iterator = array[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined, 'Exhausted result `value` (repeated request)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
result.done, true, 'Exhausted result `done` flag (repeated request)'
|
||||||
|
);
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.7 S22
|
||||||
|
description: >
|
||||||
|
Once exhausted, iterators for mapped arguments exotic objects should not
|
||||||
|
emit new values added to the object.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments[3] = 4;
|
||||||
|
arguments.length = 4;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.7 S22
|
||||||
|
description: >
|
||||||
|
Prior to being exhausted, iterators for mapped arguments exotic objects
|
||||||
|
should honor the insertion of additional argument values.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments.length = 4;
|
||||||
|
arguments[3] = 5;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 5, 'New result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'New result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.7 S22
|
||||||
|
description: >
|
||||||
|
Mapped arguments exotic objects should implement the Array iterator
|
||||||
|
protocol.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.7 S22
|
||||||
|
description: >
|
||||||
|
Prior to being exhausted, iterators for mapped arguments exotic objects
|
||||||
|
should honor argument removal.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments.length = 2;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.7 S22
|
||||||
|
description: >
|
||||||
|
Mapped arguments exotic objects should implement the Array iterator
|
||||||
|
protocol.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(arguments, Symbol.iterator);
|
||||||
|
|
||||||
|
assert.sameValue(arguments[Symbol.iterator], [][Symbol.iterator]);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Array.prototype, Symbol.iterator);
|
||||||
|
verifyWritable(Array.prototype, Symbol.iterator);
|
||||||
|
verifyConfigurable(Array.prototype, Symbol.iterator);
|
||||||
|
}());
|
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.6 S7
|
||||||
|
description: >
|
||||||
|
Once exhausted, iterators for unmapped arguments exotic objects should not
|
||||||
|
emit new values added to the object.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
'use strict';
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments[3] = 4;
|
||||||
|
arguments.length = 4;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.6 S7
|
||||||
|
description: >
|
||||||
|
Prior to being exhausted, iterators for unmapped arguments exotic objects
|
||||||
|
should honor the insertion of additional argument values.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
'use strict';
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments.length = 4;
|
||||||
|
arguments[3] = 5;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 5, 'New result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'New result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.6 S7
|
||||||
|
description: >
|
||||||
|
Unmapped arguments exotic objects should implement the Array iterator
|
||||||
|
protocol.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
'use strict';
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 2, 'First result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 1, 'Second result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||||
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.6 S7
|
||||||
|
description: >
|
||||||
|
Prior to being exhausted, iterators for unmapped arguments exotic objects
|
||||||
|
should honor argument removal.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
'use strict';
|
||||||
|
var iterator = arguments[Symbol.iterator]();
|
||||||
|
var result;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
iterator.next();
|
||||||
|
|
||||||
|
arguments.length = 2;
|
||||||
|
|
||||||
|
result = iterator.next();
|
||||||
|
assert.sameValue(result.value, undefined, 'Exhausted result `value`');
|
||||||
|
assert.sameValue(result.done, true, 'Exhausted result `done` flag');
|
||||||
|
}(2, 1, 3));
|
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 9.4.4.6 S7
|
||||||
|
description: >
|
||||||
|
Unmapped arguments exotic objects should implement the Array iterator
|
||||||
|
protocol.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
var descriptor = Object.getOwnPropertyDescriptor(arguments, Symbol.iterator);
|
||||||
|
|
||||||
|
assert.sameValue(arguments[Symbol.iterator], [][Symbol.iterator]);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Array.prototype, Symbol.iterator);
|
||||||
|
verifyWritable(Array.prototype, Symbol.iterator);
|
||||||
|
verifyConfigurable(Array.prototype, Symbol.iterator);
|
||||||
|
}());
|
26
test/language/for-of/arguments-object-aliasing.js
Normal file
26
test/language/for-of/arguments-object-aliasing.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) Copyright 2014 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: >
|
||||||
|
Arguments objects should be able to be traversed using a `for..of` loop,
|
||||||
|
and dynamic changes to their contents should be reflected in the iterated
|
||||||
|
values.
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expected = [1, 3, 1];
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
(function(a, b, c) {
|
||||||
|
for (var value of arguments) {
|
||||||
|
a = b;
|
||||||
|
b = c;
|
||||||
|
c = i;
|
||||||
|
assert.sameValue(value, expected[i], 'argument at index ' + i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}(1, 2, 3));
|
||||||
|
|
||||||
|
assert.sameValue(i, 3, 'Visits all arguments');
|
22
test/language/for-of/arguments-object-mutation.js
Normal file
22
test/language/for-of/arguments-object-mutation.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) Copyright 2014 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: >
|
||||||
|
Arguments objects should be able to be traversed using a `for..of` loop,
|
||||||
|
and dynamic changes to their contents should be reflected in the iterated
|
||||||
|
values.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expected = [1, 4, 6];
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
for (var value of arguments) {
|
||||||
|
assert.sameValue(value, expected[i], 'argument at index ' + i);
|
||||||
|
i++;
|
||||||
|
arguments[i] *= 2;
|
||||||
|
}
|
||||||
|
}(1, 2, 3));
|
||||||
|
|
||||||
|
assert.sameValue(i, 3, 'Visits all arguments');
|
18
test/language/for-of/arguments-object.js
Normal file
18
test/language/for-of/arguments-object.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) Copyright 2014 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: >
|
||||||
|
Arguments objects should be able to be traversed using a `for..of` loop.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
for (var value of arguments) {
|
||||||
|
assert.sameValue(value, arguments[i], 'argument at index ' + i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}(0, 'a', true, false, null, undefined, NaN));
|
||||||
|
|
||||||
|
assert.sameValue(i, 7, 'Visits all arguments');
|
Loading…
x
Reference in New Issue
Block a user