Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/superclass-async-generator-function.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-runtime-semantics-classdefinitionevaluation
5 description: >
6 IsConstructor check is performed before "prototype" lookup.
7 Async generator functions are not constructors (MakeConstructor is not called on them).
8 info: |
9 ClassDefinitionEvaluation
10
11 [...]
12 5. Else,
13 [...]
14 d. Let superclass be ? GetValue(superclassRef).
15 e. If superclass is null, then
16 [...]
17 f. Else if IsConstructor(superclass) is false, throw a TypeError exception.
18 features: [async-iteration, class, Proxy]
19 ---*/
20
21 async function* fn() {}
22
23 assert.throws(TypeError, function() {
24 class A extends fn {}
25 });
26
27 var bound = (async function* () {}).bind();
28 Object.defineProperty(bound, "prototype", {
29 get: function() {
30 throw new Test262Error("`superclass.prototype` is unreachable");
31 },
32 });
33
34 assert.throws(TypeError, function() {
35 class C extends bound {}
36 });
37
38 var proxy = new Proxy(async function* () {}, {});
39
40 assert.throws(TypeError, function() {
41 class C extends proxy {}
42 });
43
44 reportCompare(0, 0);