Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/concat/iterable-primitive-wrapper-objects.js

raw
1 // |reftest| shell-option(--enable-iterator-sequencing) skip-if(!Iterator.concat||!xulRuntime.shell) -- iterator-sequencing is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Michael Ficarra. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-iterator.concat
7 description: >
8 Does not throw an error for iterable primitive wrapper objects
9 info: |
10 Iterator.concat ( ...items )
11
12 1. Let iterables be a new empty List.
13 2. For each element item of items, do
14 a. If item is not an Object, throw a TypeError exception.
15 ...
16 features: [iterator-sequencing]
17 ---*/
18
19 let desc = {
20 value: function() {
21 return {
22 next: function() {
23 return { done: true, value: undefined };
24 },
25 };
26 },
27 writable: false,
28 enumerable: false,
29 configurable: true,
30 };
31
32 Object.defineProperty(Boolean.prototype, Symbol.iterator, desc);
33 Object.defineProperty(Number.prototype, Symbol.iterator, desc);
34 Object.defineProperty(BigInt.prototype, Symbol.iterator, desc);
35 // NOTE: String.prototype already has a Symbol.iterator property
36 Object.defineProperty(Symbol.prototype, Symbol.iterator, desc);
37
38 Iterator.concat(
39 Object(true),
40 Object(123),
41 Object(123n),
42 Object("test"),
43 Object(Symbol()),
44 ).next();
45
46 reportCompare(0, 0);