Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // A set iterator can cope with removing the current entry.
3 function test(letters, toRemove) {
4 var set = Set(letters);
5 toRemove = Set(toRemove);
7 var leftovers = [x for (x of set) if (!toRemove.has(x))].join("");
9 var log = "";
10 for (let x of set) {
11 log += x;
12 if (toRemove.has(x))
13 set.delete(x);
14 }
15 assertEq(log, letters);
17 var remaining = [x for (x of set)].join("");
18 assertEq(remaining, leftovers);
19 }
21 test('a', 'a'); // removing the only entry
22 test('abc', 'a'); // removing the first entry
23 test('abc', 'b'); // removing a middle entry
24 test('abc', 'c'); // removing the last entry
25 test('abc', 'abc') // removing all entries