fix super evaluation order tests

This commit is contained in:
Gus Caplan 2020-02-14 22:37:51 -08:00 committed by Rick Waldron
parent 602cdaca46
commit 922e27fd8c
3 changed files with 14 additions and 63 deletions

View File

@ -1,29 +0,0 @@
// Copyright (C) 2020 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: prod-SuperCall
description: SuperCall should evaluate Arguments prior to checking IsConstructable
info: |
GetSuperConstructor ( )
[...]
1. Let _func_ be ! GetSuperConstructor().
2. Let _argList_ be ? ArgumentListEvaluation of |Arguments|.
3. If IsConstructor(_func_) is *false*, throw a *TypeError* exception.
[...]
features: [default-parameters]
---*/
var x = 0;
class C extends Object {
constructor() {
super(x = 123);
}
}
Object.setPrototypeOf(C, parseInt);
assert.throws(TypeError, () => {
new C();
});
assert.sameValue(x, 123, 'via ArgumentListEvaluation');

View File

@ -3,43 +3,29 @@
/*--- /*---
esid: sec-super-keyword esid: sec-super-keyword
es6id: 12.3.5 es6id: 12.3.5
description: Prototype of active function object must be a constructor description: SuperCall should evaluate Arguments prior to checking IsConstructor
info: | info: |
[...] SuperCall : `super` Arguments
3. Let func be ? GetSuperConstructor().
12.3.5.2 Runtime Semantics: GetSuperConstructor
[...] [...]
4. Let superConstructor be ? activeFunction.[[GetPrototypeOf]](). 3. Let _func_ be ! GetSuperConstructor().
5. If IsConstructor(superConstructor) is false, throw a TypeError exception. 4. Let _argList_ be ? ArgumentListEvaluation of |Arguments|.
5. If IsConstructor(_func_) is *false*, throw a *TypeError* exception.
[...]
features: [class] features: [class]
---*/ ---*/
var evaluatedArg = false; var evaluatedArg = false;
var caught;
class C extends Object { class C extends Object {
constructor() { constructor() {
try { super(evaluatedArg = true);
super(evaluatedArg = true);
} catch (err) {
caught = err;
}
} }
} }
Object.setPrototypeOf(C, parseInt); Object.setPrototypeOf(C, parseInt);
// When the "construct" invocation completes and the "this" value is assert.throws(TypeError, () => {
// 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(); new C();
} catch (_) {} });
assert.sameValue(typeof caught, 'object'); assert(evaluatedArg, 'performs ArgumentsListEvaluation');
assert.sameValue(caught.constructor, TypeError);
assert.sameValue(
evaluatedArg, false, 'did not perform ArgumentsListEvaluation'
);

View File

@ -27,15 +27,9 @@ info: |
SuperCall : super Arguments SuperCall : super Arguments
[...] [...]
3. Let func be ? GetSuperConstructor(). 3. Let func be ! GetSuperConstructor().
4. Let argList be ArgumentListEvaluation of Arguments. 4. Let argList be ? ArgumentListEvaluation of Arguments.
[...] 5. If IsConstructor(func) is false, throw a TypeError exception.
12.3.5.2 Runtime Semantics: GetSuperConstructor ( )
[...]
5. Let superConstructor be ! activeFunction.[[GetPrototypeOf]]().
6. If IsConstructor(superConstructor) is false, throw a TypeError exception.
[...] [...]
---*/ ---*/
@ -45,7 +39,7 @@ var reachable = 0;
class C extends null { class C extends null {
constructor() { constructor() {
reachable += 1; reachable += 1;
super(unreachable += 1); super();
unreachable += 1; unreachable += 1;
} }
} }