mirror of https://github.com/tc39/test262.git
fix super evaluation order tests
This commit is contained in:
parent
602cdaca46
commit
922e27fd8c
|
@ -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');
|
|
@ -3,43 +3,29 @@
|
|||
/*---
|
||||
esid: sec-super-keyword
|
||||
es6id: 12.3.5
|
||||
description: Prototype of active function object must be a constructor
|
||||
description: SuperCall should evaluate Arguments prior to checking IsConstructor
|
||||
info: |
|
||||
[...]
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
|
||||
12.3.5.2 Runtime Semantics: GetSuperConstructor
|
||||
SuperCall : `super` Arguments
|
||||
|
||||
[...]
|
||||
4. Let superConstructor be ? activeFunction.[[GetPrototypeOf]]().
|
||||
5. If IsConstructor(superConstructor) is false, throw a TypeError exception.
|
||||
3. Let _func_ be ! GetSuperConstructor().
|
||||
4. Let _argList_ be ? ArgumentListEvaluation of |Arguments|.
|
||||
5. If IsConstructor(_func_) is *false*, throw a *TypeError* exception.
|
||||
[...]
|
||||
features: [class]
|
||||
---*/
|
||||
|
||||
var evaluatedArg = false;
|
||||
var caught;
|
||||
class C extends Object {
|
||||
constructor() {
|
||||
try {
|
||||
super(evaluatedArg = true);
|
||||
} catch (err) {
|
||||
caught = err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(C, parseInt);
|
||||
|
||||
// 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 {
|
||||
assert.throws(TypeError, () => {
|
||||
new C();
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
assert.sameValue(typeof caught, 'object');
|
||||
assert.sameValue(caught.constructor, TypeError);
|
||||
assert.sameValue(
|
||||
evaluatedArg, false, 'did not perform ArgumentsListEvaluation'
|
||||
);
|
||||
assert(evaluatedArg, 'performs ArgumentsListEvaluation');
|
||||
|
|
|
@ -27,15 +27,9 @@ info: |
|
|||
SuperCall : super Arguments
|
||||
|
||||
[...]
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
[...]
|
||||
|
||||
12.3.5.2 Runtime Semantics: GetSuperConstructor ( )
|
||||
|
||||
[...]
|
||||
5. Let superConstructor be ! activeFunction.[[GetPrototypeOf]]().
|
||||
6. If IsConstructor(superConstructor) is false, throw a TypeError exception.
|
||||
3. Let func be ! GetSuperConstructor().
|
||||
4. Let argList be ? ArgumentListEvaluation of Arguments.
|
||||
5. If IsConstructor(func) is false, throw a TypeError exception.
|
||||
[...]
|
||||
---*/
|
||||
|
||||
|
@ -45,7 +39,7 @@ var reachable = 0;
|
|||
class C extends null {
|
||||
constructor() {
|
||||
reachable += 1;
|
||||
super(unreachable += 1);
|
||||
super();
|
||||
unreachable += 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue