Update call-proto-not-ctor.js

This commit is contained in:
Gus Caplan 2020-02-17 23:47:18 -08:00 committed by Rick Waldron
parent 922e27fd8c
commit b3c94b3268
1 changed files with 14 additions and 4 deletions

View File

@ -2,7 +2,6 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-super-keyword
es6id: 12.3.5
description: SuperCall should evaluate Arguments prior to checking IsConstructor
info: |
SuperCall : `super` Arguments
@ -16,16 +15,27 @@ features: [class]
---*/
var evaluatedArg = false;
var caught;
class C extends Object {
constructor() {
super(evaluatedArg = true);
try {
super(evaluatedArg = true);
} catch (err) {
caught = err;
}
}
}
Object.setPrototypeOf(C, parseInt);
assert.throws(TypeError, () => {
// When the "construct" invocation completes and the "this" value is
// uninitialized, the specification dictates that a ReferenceError must be
// thrown. That behavior is tested elsewhere, so the error is ignored (if it is
// produced at all).
try {
new C();
});
} catch (_) {}
assert.sameValue(typeof caught, 'object');
assert.sameValue(caught.constructor, TypeError);
assert(evaluatedArg, 'performs ArgumentsListEvaluation');