Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/subclassable.js

raw
1 // |reftest| shell-option(--enable-iterator-helpers) skip-if(!this.hasOwnProperty('Iterator')||!xulRuntime.shell) -- iterator-helpers is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-iterator-constructor
7 description: >
8 The Iterator constructor is designed to be subclassable.
9 info: |
10 The Iterator constructor
11
12 - is designed to be subclassable. It may be used as the value of an extends clause of a class defintion.
13
14 features: [iterator-helpers]
15 ---*/
16
17 class SubIterator extends Iterator {}
18
19 assert.sameValue(
20 new SubIterator() instanceof SubIterator,
21 true,
22 'The result of `(new SubIterator() instanceof SubIterator)` is true'
23 );
24 assert.sameValue(
25 new SubIterator() instanceof Iterator,
26 true,
27 'The result of `(new SubIterator() instanceof Iterator)` is true'
28 );
29
30 reportCompare(0, 0);