diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js new file mode 100644 index 0000000000..4a6eb0a13e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.forEach +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + New values added after the call to forEach begins are visited. + +---*/ + + +var s = new Set([1]); +var expects = [1, 2, 3]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + if (value === 1) { + set.add(2); + } + + if (value === 2) { + set.add(3); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); |