mirror of https://github.com/tc39/test262.git
Add tests for setting class-name in ClassDefinitionEvaluation (#2057)
Spec PR: tc39/ecma262#1372
This commit is contained in:
parent
fb9bb7502f
commit
3efcde4ba7
|
@ -21,6 +21,6 @@ assert(
|
||||||
"`compareArray(Object.keys(C), [])` returns `true`"
|
"`compareArray(Object.keys(C), [])` returns `true`"
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name']),
|
compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c']),
|
||||||
"`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name'])` returns `true`"
|
"`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c'])` returns `true`"
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,6 +21,6 @@ assert(
|
||||||
"`compareArray(Object.keys(C), [])` returns `true`"
|
"`compareArray(Object.keys(C), [])` returns `true`"
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name']),
|
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd']),
|
||||||
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name'])` returns `true`"
|
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd'])` returns `true`"
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,8 +24,8 @@ assert(
|
||||||
"`compareArray(Object.keys(C), [])` returns `true`"
|
"`compareArray(Object.keys(C), [])` returns `true`"
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name']),
|
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c']),
|
||||||
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name'])` returns `true`"
|
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c'])` returns `true`"
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]),
|
compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]),
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2019 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
|
description: >
|
||||||
|
The inferred class-name is present when executing static field initializers of anonymous class expressions.
|
||||||
|
info: |
|
||||||
|
14.6.13 Runtime Semantics: ClassDefinitionEvaluation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
17. Perform MakeClassConstructor(F).
|
||||||
|
18. If className is not undefined, then
|
||||||
|
a. Perform SetFunctionName(F, className).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
features: [class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var className;
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
static f = (className = this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(className, "C");
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2019 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
|
description: >
|
||||||
|
The class-name is present when executing static field initializers of class declarations.
|
||||||
|
info: |
|
||||||
|
14.6.13 Runtime Semantics: ClassDefinitionEvaluation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
17. Perform MakeClassConstructor(F).
|
||||||
|
18. If className is not undefined, then
|
||||||
|
a. Perform SetFunctionName(F, className).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
features: [class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var className;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static f = (className = this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(className, "C");
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2019 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
|
description: >
|
||||||
|
The class-name is present when executing static field initializers of default-exported classes.
|
||||||
|
info: |
|
||||||
|
14.6.13 Runtime Semantics: ClassDefinitionEvaluation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
17. Perform MakeClassConstructor(F).
|
||||||
|
18. If className is not undefined, then
|
||||||
|
a. Perform SetFunctionName(F, className).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
flags: [module]
|
||||||
|
features: [class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var className;
|
||||||
|
|
||||||
|
export default class {
|
||||||
|
static f = (className = this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(className, "default");
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2019 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
|
description: >
|
||||||
|
The class-name is present when executing static field initializers of named class expressions.
|
||||||
|
info: |
|
||||||
|
14.6.13 Runtime Semantics: ClassDefinitionEvaluation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
17. Perform MakeClassConstructor(F).
|
||||||
|
18. If className is not undefined, then
|
||||||
|
a. Perform SetFunctionName(F, className).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
features: [class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var className;
|
||||||
|
|
||||||
|
var expr = class C {
|
||||||
|
static f = (className = this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(className, "C");
|
Loading…
Reference in New Issue