mirror of https://github.com/tc39/test262.git
test: Check private methods are not installed before super returns
This commit is contained in:
parent
6f4c0d96f7
commit
27beedc281
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private getters are installed "when super returns" and no earlier (call in constructor)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
constructor() {
|
||||
this.f();
|
||||
}
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
f() { this.#m; }
|
||||
get #m() { return 42; }
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('f'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private getters are not installed before super returns');
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private getters are installed "when super returns" and no earlier (call in field initializer)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
f = this.g();
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
g() { this.#m; }
|
||||
get #m() { return 42; }
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('g'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private getters are not installed before super returns');
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private methods are installed "when super returns" and no earlier (call in constructor)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
constructor() {
|
||||
this.f();
|
||||
}
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
f() { this.#m(); }
|
||||
#m() { return 42; }
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('f'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private methods are not installed before super returns');
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private methods are installed "when super returns" and no earlier (call in field initializer)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
f = this.g();
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
g() { this.#m(); }
|
||||
#m() { return 42; }
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('g'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private methods are not installed before super returns');
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private setters are installed "when super returns" and no earlier (call in constructor)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
constructor() {
|
||||
this.f();
|
||||
}
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
f() { this.#m = 42; }
|
||||
set #m(val) {}
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('f'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private setters are not installed before super returns');
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (C) 2019 Kubilay Kahveci (Bloomberg LP). All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Private settters are installed "when super returns" and no earlier (call in field initializer)
|
||||
info: |
|
||||
SuperCall: super Arguments
|
||||
1. Let newTarget be GetNewTarget().
|
||||
2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
3. Let func be ? GetSuperConstructor().
|
||||
4. Let argList be ArgumentListEvaluation of Arguments.
|
||||
5. ReturnIfAbrupt(argList).
|
||||
6. Let result be ? Construct(func, argList, newTarget).
|
||||
7. Let thisER be GetThisEnvironment( ).
|
||||
8. Let F be thisER.[[FunctionObject]].
|
||||
9. Assert: F is an ECMAScript function object.
|
||||
10. Perform ? InitializeInstanceElements(result, F).
|
||||
|
||||
EDITOR'S NOTE:
|
||||
Private fields are added to the object one by one, interspersed with
|
||||
evaluation of the initializers, following the construction of the
|
||||
receiver. These semantics allow for a later initializer to refer to
|
||||
a previous private field.
|
||||
template: default
|
||||
features: [class-methods-private]
|
||||
---*/
|
||||
|
||||
//- elements
|
||||
f = this.g();
|
||||
|
||||
//- assertions
|
||||
class D extends C {
|
||||
g() { this.#m = 42; }
|
||||
set #m(val) {}
|
||||
}
|
||||
|
||||
assert(D.prototype.hasOwnProperty('g'));
|
||||
assert.throws(TypeError, function() {
|
||||
var d = new D();
|
||||
}, 'private setters are not installed before super returns');
|
Loading…
Reference in New Issue