Debian Codegraph @

js/src/tests/test262/language/expressions/super/call-proto-not-ctor.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-super-keyword
5 description: SuperCall should evaluate Arguments prior to checking IsConstructor
6 info: |
7 SuperCall : `super` Arguments
8
9 [...]
10 3. Let _func_ be ! GetSuperConstructor().
11 4. Let _argList_ be ? ArgumentListEvaluation of |Arguments|.
12 5. If IsConstructor(_func_) is *false*, throw a *TypeError* exception.
13 [...]
14 features: [class]
15 ---*/
16
17 var evaluatedArg = false;
18 var caught;
19 class C extends Object {
20 constructor() {
21 try {
22 super(evaluatedArg = true);
23 } catch (err) {
24 caught = err;
25 }
26 }
27 }
28
29 Object.setPrototypeOf(C, parseInt);
30
31 // When the "construct" invocation completes and the "this" value is
32 // uninitialized, the specification dictates that a ReferenceError must be
33 // thrown. That behavior is tested elsewhere, so the error is ignored (if it is
34 // produced at all).
35 try {
36 new C();
37 } catch (_) {}
38
39 assert.sameValue(typeof caught, 'object');
40 assert.sameValue(caught.constructor, TypeError);
41 assert(evaluatedArg, 'performs ArgumentsListEvaluation');
42
43 reportCompare(0, 0);