diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/ArrayIteratorPrototype/next | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/ArrayIteratorPrototype/next')
26 files changed, 929 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float32Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float32Array.js new file mode 100644 index 0000000000..c99780c4e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float32Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float64Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float64Array.js new file mode 100644 index 0000000000..7b51a97bf4 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Float64Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int16Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int16Array.js new file mode 100644 index 0000000000..40e70e4956 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int16Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int32Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int32Array.js new file mode 100644 index 0000000000..9ee7ef0c40 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int32Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int8Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int8Array.js new file mode 100644 index 0000000000..be49297ba0 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Int8Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint16Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint16Array.js new file mode 100644 index 0000000000..5227b2da30 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint16Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint32Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint32Array.js new file mode 100644 index 0000000000..a2ee3d6ddb --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint32Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8Array.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8Array.js new file mode 100644 index 0000000000..b5ac6e4da3 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8Array.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8ClampedArray.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8ClampedArray.js new file mode 100644 index 0000000000..0c93d303ac --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/Uint8ClampedArray.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Visits each element of the array in order and ceases iteration once all + values have been visited. +features: [Symbol.iterator, TypedArray] +---*/ +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)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-after-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-after-exhaustion.js new file mode 100644 index 0000000000..def61445ae --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-after-exhaustion.js @@ -0,0 +1,29 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Once exhausted, iterators for mapped arguments exotic objects should not + emit new values added to the object. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-before-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-before-exhaustion.js new file mode 100644 index 0000000000..1f3273a196 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-expansion-before-exhaustion.js @@ -0,0 +1,32 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Prior to being exhausted, iterators for mapped arguments exotic objects + should honor the insertion of additional argument values. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-iteration.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-iteration.js new file mode 100644 index 0000000000..fd00e40907 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-iteration.js @@ -0,0 +1,33 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Mapped arguments exotic objects should implement the Array iterator + protocol. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-truncation-before-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-truncation-before-exhaustion.js new file mode 100644 index 0000000000..19a8799abd --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-mapped-truncation-before-exhaustion.js @@ -0,0 +1,26 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Prior to being exhausted, iterators for mapped arguments exotic objects + should honor argument removal. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-after-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-after-exhaustion.js new file mode 100644 index 0000000000..667a7fe047 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-after-exhaustion.js @@ -0,0 +1,30 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Once exhausted, iterators for unmapped arguments exotic objects should not + emit new values added to the object. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-before-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-before-exhaustion.js new file mode 100644 index 0000000000..09dcc31b37 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-expansion-before-exhaustion.js @@ -0,0 +1,33 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Prior to being exhausted, iterators for unmapped arguments exotic objects + should honor the insertion of additional argument values. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-iteration.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-iteration.js new file mode 100644 index 0000000000..967ddd069a --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-iteration.js @@ -0,0 +1,34 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Unmapped arguments exotic objects should implement the Array iterator + protocol. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-truncation-before-exhaustion.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-truncation-before-exhaustion.js new file mode 100644 index 0000000000..155221d082 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/args-unmapped-truncation-before-exhaustion.js @@ -0,0 +1,27 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + Prior to being exhausted, iterators for unmapped arguments exotic objects + should honor argument removal. +flags: [noStrict] +features: [Symbol.iterator] +---*/ + +(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)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/browser.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/browser.js diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js new file mode 100644 index 0000000000..addce3aa70 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%arrayiteratorprototype%.next +description: If the underlying TypedArray is detached during iteration, throw +info: | + %ArrayIteratorPrototype%.next( ) + + ... + 8. If _a_ has a [[TypedArrayName]] internal slot, then + a. If IsDetachedBuffer(_a_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception. +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(TA => { + var typedArray = new TA(5); + var i = 0; + assert.throws(TypeError, () => { + for (let key of typedArray.keys()) { + $DETACHBUFFER(typedArray.buffer); + i++; + } + }); + assert.sameValue(i, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration-mutable.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration-mutable.js new file mode 100644 index 0000000000..4e1160e4c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration-mutable.js @@ -0,0 +1,36 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + 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 + 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: 22.1.3.30 +features: [Symbol.iterator] +---*/ + +var array = []; +var iterator = array[Symbol.iterator](); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value, 'a', 'First result `value`'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag (after push)'); +assert.sameValue(result.value, undefined, 'Exhausted result `value (after push)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration.js new file mode 100644 index 0000000000..58803cf64d --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/iteration.js @@ -0,0 +1,33 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + The method should return a valid iterator with the context as the + IteratedObject. +es6id: 22.1.3.30 +features: [Symbol.iterator] +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array[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'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js new file mode 100644 index 0000000000..22f673c500 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + %ArrayIteratorPrototype%.next.length is 0. +info: | + %ArrayIteratorPrototype%.next( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue(ArrayIteratorProto.next.length, 0); + +verifyNotEnumerable(ArrayIteratorProto.next, "length"); +verifyNotWritable(ArrayIteratorProto.next, "length"); +verifyConfigurable(ArrayIteratorProto.next, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js new file mode 100644 index 0000000000..b6e90d9645 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + %ArrayIteratorPrototype%.next.name is "next". +info: | + %ArrayIteratorPrototype%.next( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue(ArrayIteratorProto.next.name, "next"); + +verifyNotEnumerable(ArrayIteratorProto.next, "name"); +verifyNotWritable(ArrayIteratorProto.next, "name"); +verifyConfigurable(ArrayIteratorProto.next, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/non-own-slots.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/non-own-slots.js new file mode 100644 index 0000000000..fdac743d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/non-own-slots.js @@ -0,0 +1,20 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + If the `this` value does not have all of the internal slots of an Array + Iterator Instance (22.1.5.3), throw a TypeError exception. +esid: sec-%arrayiteratorprototype%.next +features: [Symbol.iterator] +---*/ + +var array = [0]; +var iterator = array[Symbol.iterator](); +var object = Object.create(iterator); + +assert.throws(TypeError, function() { + object.next(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/property-descriptor.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/property-descriptor.js new file mode 100644 index 0000000000..65361cddc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/property-descriptor.js @@ -0,0 +1,19 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%arrayiteratorprototype%.next +description: > + The method should exist on the ArrayIterator prototype, and it should be + writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +verifyNotEnumerable(ArrayIteratorProto, 'next'); +verifyWritable(ArrayIteratorProto, 'next'); +verifyConfigurable(ArrayIteratorProto, 'next'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/shell.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/shell.js new file mode 100644 index 0000000000..f9aa35231b --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/shell.js @@ -0,0 +1,142 @@ +// GENERATED, DO NOT EDIT +// file: detachArrayBuffer.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. +defines: [$DETACHBUFFER] +---*/ + +function $DETACHBUFFER(buffer) { + if (!$262 || typeof $262.detachArrayBuffer !== "function") { + throw new Test262Error("No method available to detach an ArrayBuffer"); + } + $262.detachArrayBuffer(buffer); +} + +// file: testTypedArray.js +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} |