Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/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 es6id: 12.3.5
6 description: Prototype of active function object must be a constructor
7 info: |
8 [...]
9 3. Let func be ? GetSuperConstructor().
10
11 12.3.5.2 Runtime Semantics: GetSuperConstructor
12
13 [...]
14 4. Let superConstructor be ? activeFunction.[[GetPrototypeOf]]().
15 5. If IsConstructor(superConstructor) is false, throw a TypeError exception.
16 features: [class]
17 ---*/
18
19 var evaluatedArg = false;
20 var caught;
21 class C extends Object {
22 constructor() {
23 try {
24 super(evaluatedArg = true);
25 } catch (err) {
26 caught = err;
27 }
28 }
29 }
30
31 Object.setPrototypeOf(C, parseInt);
32
33 // When the "construct" invocation completes and the "this" value is
34 // uninitialized, the specification dictates that a ReferenceError must be
35 // thrown. That behavior is tested elsewhere, so the error is ignored (if it is
36 // produced at all).
37 try {
38 new C();
39 } catch (_) {}
40
41 assert.sameValue(typeof caught, 'object');
42 assert.sameValue(caught.constructor, TypeError);
43 assert.sameValue(
44 evaluatedArg, false, 'did not perform ArgumentsListEvaluation'
45 );