Add tests for setting class-name in ClassDefinitionEvaluation (#2057)

Spec PR: tc39/ecma262#1372
This commit is contained in:
André Bargull 2019-01-30 13:34:32 -08:00 committed by Leo Balter
parent fb9bb7502f
commit 3efcde4ba7
7 changed files with 111 additions and 6 deletions

View File

@ -21,6 +21,6 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`"
);
assert(
compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name']),
"`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'a', 'c', 'name'])` returns `true`"
compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c']),
"`compareArray(Object.getOwnPropertyNames(C), ['1', '2', 'length', 'prototype', 'name', 'a', 'c'])` returns `true`"
);

View File

@ -21,6 +21,6 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`"
);
assert(
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name']),
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'b', 'c', 'd', 'name'])` returns `true`"
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd']),
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'b', 'c', 'd'])` returns `true`"
);

View File

@ -24,8 +24,8 @@ assert(
"`compareArray(Object.keys(C), [])` returns `true`"
);
assert(
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name']),
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'a', 'c', 'name'])` returns `true`"
compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c']),
"`compareArray(Object.getOwnPropertyNames(C), ['length', 'prototype', 'name', 'a', 'c'])` returns `true`"
);
assert(
compareArray(Object.getOwnPropertySymbols(C), [sym1, sym2]),

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");