mirror of
https://github.com/tc39/test262.git
synced 2025-06-02 21:20:31 +02:00
Remove static fields tests
Static fields were broken up from instance fields and demoted to Stage 2 in the November 2017 TC39 meeting. This patch removes the test262 tests which test static class fields.
This commit is contained in:
parent
cb84893f93
commit
d50c33a5b3
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ info: |
|
|||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
Runtime Semantics: ClassElementEvaluation
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
ClassElement: FieldDefinition;
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
||||||
|
|
||||||
|
@ -22,17 +22,8 @@ features: [computed-property-names]
|
|||||||
var x = "b";
|
var x = "b";
|
||||||
|
|
||||||
//- fields
|
//- fields
|
||||||
static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]
|
[x] = 42; [10] = "meep"; ["not initialized"]
|
||||||
//- assertions
|
//- assertions
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "a"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "a"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "a", {
|
|
||||||
value: 39,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "b"), false);
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "b"), false);
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "b"), false);
|
assert.sameValue(Object.hasOwnProperty.call(C, "b"), false);
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
MethodDefinition
|
MethodDefinition
|
||||||
static MethodDefinition
|
static MethodDefinition
|
||||||
FieldDefinition ;
|
FieldDefinition ;
|
||||||
static FieldDefinition ;
|
|
||||||
;
|
;
|
||||||
|
|
||||||
FieldDefinition:
|
FieldDefinition:
|
||||||
|
@ -28,54 +28,38 @@ includes: [propertyHelper.js]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
//- setup
|
//- setup
|
||||||
var x = 0;
|
var x = 1;
|
||||||
//- fields
|
//- fields
|
||||||
static [x++] = x++;
|
|
||||||
[x++] = x++;
|
[x++] = x++;
|
||||||
static [x++] = x++;
|
|
||||||
[x++] = x++;
|
[x++] = x++;
|
||||||
//- assertions
|
//- assertions
|
||||||
var c1 = new C();
|
var c1 = new C();
|
||||||
var c2 = new C();
|
var c2 = new C();
|
||||||
|
|
||||||
verifyProperty(C, "0", {
|
verifyProperty(c1, "1", {
|
||||||
|
value: 3,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
writable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
verifyProperty(c1, "2", {
|
||||||
value: 4,
|
value: 4,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyProperty(C, "2", {
|
verifyProperty(c2, "1", {
|
||||||
value: 5,
|
value: 5,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyProperty(c1, "1", {
|
verifyProperty(c2, "2", {
|
||||||
value: 6,
|
value: 6,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
verifyProperty(c1, "3", {
|
|
||||||
value: 7,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(c2, "1", {
|
|
||||||
value: 8,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(c2, "3", {
|
|
||||||
value: 9,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true,
|
|
||||||
});
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-comp-name-
|
|
||||||
name: computed ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var x = "string";
|
|
||||||
class C {
|
|
||||||
static [x] = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-static-comp-name-
|
|
||||||
name: static computed ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var x = "string";
|
|
||||||
class C {
|
|
||||||
static [x] = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-static-literal-
|
|
||||||
name: static literal ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static x = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-static-private-
|
|
||||||
name: static PrivateName
|
|
||||||
features: [class, class-fields-private]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static #x = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-static-string-literal-name-
|
|
||||||
name: static string literal ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static 'x' = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-static-comp-name-
|
|
||||||
name: static computed ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var x = "string";
|
|
||||||
var C = class {
|
|
||||||
static [x] = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-static-literal-
|
|
||||||
name: static literal ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static x = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-static-private-
|
|
||||||
name: static PrivateName
|
|
||||||
features: [class, class-fields-private]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static #x = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-static-string-literal-name-
|
|
||||||
name: static string literal ClassElementName
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static 'x' = /*{ initializer }*/;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-literal-name-
|
|
||||||
name: early error -- PropName of IdentifierName is forbidden value
|
|
||||||
negative:
|
|
||||||
type: SyntaxError
|
|
||||||
phase: early
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
LiteralPropertyName : IdentifierName
|
|
||||||
Return StringValue of IdentifierName.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static /*{ propname }*/;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-string-name-
|
|
||||||
name: early error -- PropName of StringLiteral is forbidden value
|
|
||||||
negative:
|
|
||||||
type: SyntaxError
|
|
||||||
phase: early
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
LiteralPropertyName : StringLiteral
|
|
||||||
Return the String value whose code units are the SV of the StringLiteral.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static '/*{ propname }*/';
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/statements/class/fields-computed-variable-name-
|
|
||||||
name: no early error -- PropName of ComputedPropertyName not forbidden value
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
ComputedPropertyName : [ AssignmentExpression ]
|
|
||||||
Return empty.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var /*{ propname }*/ = "foo";
|
|
||||||
class C {
|
|
||||||
static [/*{ propname }*/];
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.sameValue(C.hasOwnProperty("foo"), true);
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(c.hasOwnProperty("foo"), false);
|
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-literal-name-
|
|
||||||
name: early error -- PropName of IdentifierName is forbidden
|
|
||||||
negative:
|
|
||||||
type: SyntaxError
|
|
||||||
phase: early
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
LiteralPropertyName : IdentifierName
|
|
||||||
Return StringValue of IdentifierName.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static /*{ propname }*/;
|
|
||||||
};
|
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-string-name-
|
|
||||||
name: early error -- PropName of StringLiteral is forbidden
|
|
||||||
negative:
|
|
||||||
type: SyntaxError
|
|
||||||
phase: early
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
LiteralPropertyName : StringLiteral
|
|
||||||
Return the String value whose code units are the SV of the StringLiteral.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
throw "Test262: This statement should not be evaluated.";
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static '/*{ propname }*/';
|
|
||||||
};
|
|
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
path: language/expressions/class/fields-computed-variable-name-
|
|
||||||
name: no early error -- PropName of ComputedPropertyName not forbidden value
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
ComputedPropertyName : [ AssignmentExpression ]
|
|
||||||
Return empty.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var /*{ propname }*/ = 'foo';
|
|
||||||
var C = class {
|
|
||||||
static [/*{ propname }*/];
|
|
||||||
};
|
|
||||||
|
|
||||||
assert.sameValue(C.hasOwnProperty("foo"), true);
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(c.hasOwnProperty("foo"), false);
|
|
@ -1,102 +0,0 @@
|
|||||||
// Copyright (C) 2017 Leo Balter. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: ToPrimitive evaluation in the ComputedPropertyName
|
|
||||||
info: |
|
|
||||||
Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
27. For each ClassElement e in order from elements
|
|
||||||
a. If IsStatic of me is false, then
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
|
|
||||||
b. Else,
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
|
|
||||||
c. If fields is an abrupt completion, then
|
|
||||||
i. Set the running execution context's LexicalEnvironment to lex.
|
|
||||||
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
|
|
||||||
iii. Return Completion(status).
|
|
||||||
...
|
|
||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
|
||||||
|
|
||||||
Runtime Semantics: ClassFieldDefinitionEvaluation
|
|
||||||
With parameters isStatic and homeObject.
|
|
||||||
|
|
||||||
1. Let fieldName be the result of evaluating ClassElementName.
|
|
||||||
2. ReturnIfAbrupt(fieldName).
|
|
||||||
...
|
|
||||||
|
|
||||||
Runtime Semantics: Evaluation
|
|
||||||
ComputedPropertyName: [ AssignmentExpression ]
|
|
||||||
|
|
||||||
1. Let exprValue be the result of evaluating AssignmentExpression.
|
|
||||||
2. Let propName be ? GetValue(exprValue).
|
|
||||||
3. Return ? ToPropertyKey(propName).
|
|
||||||
template: default
|
|
||||||
features: [computed-property-names, Symbol.toPrimitive, Symbol]
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
var s1 = Symbol();
|
|
||||||
var s2 = Symbol();
|
|
||||||
var s3 = Symbol();
|
|
||||||
var err = function() { throw new Test262Error(); };
|
|
||||||
var obj1 = {
|
|
||||||
[Symbol.toPrimitive]: function() { return s1; },
|
|
||||||
toString: err,
|
|
||||||
valueOf: err
|
|
||||||
};
|
|
||||||
|
|
||||||
var obj2 = {
|
|
||||||
toString: function() { return s2; },
|
|
||||||
valueOf: err
|
|
||||||
};
|
|
||||||
|
|
||||||
var obj3 = {
|
|
||||||
toString: undefined,
|
|
||||||
valueOf: function() { return s3; }
|
|
||||||
};
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static [obj1] = 42;
|
|
||||||
static [obj2] = 43;
|
|
||||||
static [obj3] = 44;
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s1), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s2), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s3), false);
|
|
||||||
|
|
||||||
verifyProperty(C, s1, {
|
|
||||||
value: 42,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(C, s2, {
|
|
||||||
value: 43,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(C, s3, {
|
|
||||||
value: 44,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, s1), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, s2), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, s3), false);
|
|
@ -1,99 +0,0 @@
|
|||||||
// Copyright (C) 2017 Leo Balter. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: ToPrimitive evaluation in the ComputedPropertyName
|
|
||||||
info: |
|
|
||||||
Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
27. For each ClassElement e in order from elements
|
|
||||||
a. If IsStatic of me is false, then
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
|
|
||||||
b. Else,
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
|
|
||||||
c. If fields is an abrupt completion, then
|
|
||||||
i. Set the running execution context's LexicalEnvironment to lex.
|
|
||||||
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
|
|
||||||
iii. Return Completion(status).
|
|
||||||
...
|
|
||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
|
||||||
|
|
||||||
ClassElement: static FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
ClassElement: FieldDefinition;
|
|
||||||
Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
|
|
||||||
|
|
||||||
Runtime Semantics: ClassFieldDefinitionEvaluation
|
|
||||||
With parameters isStatic and homeObject.
|
|
||||||
|
|
||||||
1. Let fieldName be the result of evaluating ClassElementName.
|
|
||||||
2. ReturnIfAbrupt(fieldName).
|
|
||||||
...
|
|
||||||
|
|
||||||
Runtime Semantics: Evaluation
|
|
||||||
ComputedPropertyName: [ AssignmentExpression ]
|
|
||||||
|
|
||||||
1. Let exprValue be the result of evaluating AssignmentExpression.
|
|
||||||
2. Let propName be ? GetValue(exprValue).
|
|
||||||
3. Return ? ToPropertyKey(propName).
|
|
||||||
template: default
|
|
||||||
features: [computed-property-names, Symbol.toPrimitive]
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
var err = function() { throw new Test262Error(); };
|
|
||||||
var obj1 = {
|
|
||||||
[Symbol.toPrimitive]: function() { return "d"; },
|
|
||||||
toString: err,
|
|
||||||
valueOf: err
|
|
||||||
};
|
|
||||||
|
|
||||||
var obj2 = {
|
|
||||||
toString: function() { return "e"; },
|
|
||||||
valueOf: err
|
|
||||||
};
|
|
||||||
|
|
||||||
var obj3 = {
|
|
||||||
toString: undefined,
|
|
||||||
valueOf: function() { return "f"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static [obj1] = 42;
|
|
||||||
static [obj2] = 43;
|
|
||||||
static [obj3] = 44;
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "d"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "e"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "f"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "d", {
|
|
||||||
value: 42,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(C, "e", {
|
|
||||||
value: 43,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(C, "f", {
|
|
||||||
value: 44,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "d"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "e"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "f"), false);
|
|
@ -1,39 +0,0 @@
|
|||||||
// Copyright (C) 2017 the V8 project authors, 2017 Igalia S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: Static Computed property names
|
|
||||||
info: |
|
|
||||||
ClassElement:
|
|
||||||
...
|
|
||||||
FieldDefinition ;
|
|
||||||
static FieldDefinition ;
|
|
||||||
|
|
||||||
FieldDefinition:
|
|
||||||
ClassElementName Initializer_opt
|
|
||||||
|
|
||||||
ClassElementName:
|
|
||||||
PropertyName
|
|
||||||
template: productions
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [computed-property-names]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static ["a"] = 42; ["a"] = 39
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "a"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "a", {
|
|
||||||
value: 42,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
verifyProperty(c, "a", {
|
|
||||||
value: 39,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2017 the V8 project authors, 2017 Igalia S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: Static computed property symbol names
|
|
||||||
info: |
|
|
||||||
ClassElement:
|
|
||||||
...
|
|
||||||
FieldDefinition ;
|
|
||||||
|
|
||||||
FieldDefinition:
|
|
||||||
ClassElementName Initializer_opt
|
|
||||||
|
|
||||||
ClassElementName:
|
|
||||||
PropertyName
|
|
||||||
template: productions
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [Symbol, computed-property-names]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
var x = Symbol();
|
|
||||||
var y = Symbol();
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static [x]; static [y] = 42
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, x), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, x), false);
|
|
||||||
|
|
||||||
verifyProperty(C, x, {
|
|
||||||
value: undefined,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, y), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, y), false);
|
|
||||||
|
|
||||||
verifyProperty(C, y, {
|
|
||||||
value: 42,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "x"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "x"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "x"), false);
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "y"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "y"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "y"), false);
|
|
@ -1,56 +0,0 @@
|
|||||||
// Copyright (C) 2017 the V8 project authors, 2017 Igalia S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: Static literal property names
|
|
||||||
info: |
|
|
||||||
ClassElement:
|
|
||||||
...
|
|
||||||
FieldDefinition ;
|
|
||||||
|
|
||||||
FieldDefinition:
|
|
||||||
ClassElementName Initializer_opt
|
|
||||||
|
|
||||||
ClassElementName:
|
|
||||||
PropertyName
|
|
||||||
template: productions
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
const fn = function() {}
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static a; b = 42;
|
|
||||||
static c = fn
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "a"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "a"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "a", {
|
|
||||||
value: undefined,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "b"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "b"), false);
|
|
||||||
|
|
||||||
verifyProperty(c, "b", {
|
|
||||||
value: 42,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "c"), false);
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "c"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "c", {
|
|
||||||
value: fn,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: literal private names
|
|
||||||
info: |
|
|
||||||
ClassElement:
|
|
||||||
...
|
|
||||||
static FieldDefinition ;
|
|
||||||
|
|
||||||
FieldDefinition:
|
|
||||||
ClassElementName Initializer_opt
|
|
||||||
|
|
||||||
ClassElementName:
|
|
||||||
PrivateName
|
|
||||||
|
|
||||||
PrivateName:
|
|
||||||
#IdentifierName
|
|
||||||
template: productions
|
|
||||||
features: [class-fields-private]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- fields
|
|
||||||
static #x; static #y
|
|
||||||
//- privateinspectionfunctions
|
|
||||||
static x() {
|
|
||||||
this.#x = 42;
|
|
||||||
return this.#x;
|
|
||||||
}
|
|
||||||
static y() {
|
|
||||||
this.#y = 43;
|
|
||||||
return this.#y;
|
|
||||||
}
|
|
||||||
//- assertions
|
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
|
|
||||||
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
|
|
||||||
|
|
||||||
// Test if private fields can be sucessfully accessed and set to value
|
|
||||||
assert.sameValue(C.x(), 42, "test 7");
|
|
||||||
assert.sameValue(C.y(), 43, "test 8");
|
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");
|
|
@ -1,18 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: static class field forbid PropName 'constructor'
|
|
||||||
info: |
|
|
||||||
|
|
||||||
// This test file tests the following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor".
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
template: propname-error-static
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- propname
|
|
||||||
constructor
|
|
@ -1,18 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: static class fields forbid PropName 'prototype'
|
|
||||||
info: |
|
|
||||||
|
|
||||||
// This test file tests the following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor".
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
template: propname-error-static
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- propname
|
|
||||||
prototype
|
|
@ -1,47 +0,0 @@
|
|||||||
// Copyright (C) 2017 Leo Balter. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: Redeclaration of public static fields with the same name
|
|
||||||
info: |
|
|
||||||
2.13.2 Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
30. Set the value of F's [[Fields]] internal slot to fieldRecords.
|
|
||||||
...
|
|
||||||
33. Let result be InitializeStaticFields(F).
|
|
||||||
|
|
||||||
InitializeStaticFields(F)
|
|
||||||
|
|
||||||
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
|
|
||||||
4. For each item fieldRecord in order from fieldRecords,
|
|
||||||
a. If fieldRecord.[[static]] is true, then
|
|
||||||
i. Perform ? DefineField(F, fieldRecord).
|
|
||||||
|
|
||||||
template: default
|
|
||||||
includes: [propertyHelper.js, compareArray.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
var x = [];
|
|
||||||
var y = Symbol();
|
|
||||||
//- fields
|
|
||||||
static [y] = (x.push("a"), "old_value");
|
|
||||||
static [y] = (x.push("b"), "same_value");
|
|
||||||
static [y] = (x.push("c"), "same_value");
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, y), false);
|
|
||||||
|
|
||||||
verifyProperty(C, y, {
|
|
||||||
value: "same_value",
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert(compareArray(x, ["a", "b", "c"]));
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, y), false);
|
|
||||||
|
|
||||||
assert(compareArray(x, ["a", "b", "c"]), "static fields are not redefined on class instatiation");
|
|
@ -1,47 +0,0 @@
|
|||||||
// Copyright (C) 2017 Leo Balter. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
desc: Redeclaration of public static fields with the same name
|
|
||||||
info: |
|
|
||||||
2.13.2 Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
30. Set the value of F's [[Fields]] internal slot to fieldRecords.
|
|
||||||
...
|
|
||||||
33. Let result be InitializeStaticFields(F).
|
|
||||||
|
|
||||||
InitializeStaticFields(F)
|
|
||||||
|
|
||||||
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
|
|
||||||
4. For each item fieldRecord in order from fieldRecords,
|
|
||||||
a. If fieldRecord.[[static]] is true, then
|
|
||||||
i. Perform ? DefineField(F, fieldRecord).
|
|
||||||
|
|
||||||
template: default
|
|
||||||
includes: [propertyHelper.js, compareArray.js]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
//- setup
|
|
||||||
var x = [];
|
|
||||||
//- fields
|
|
||||||
static y = (x.push("a"), "old_value");
|
|
||||||
static ["y"] = (x.push("b"), "another_value");
|
|
||||||
static "y" = (x.push("c"), "same_value");
|
|
||||||
static y = (x.push("d"), "same_value");
|
|
||||||
//- assertions
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "y"), false);
|
|
||||||
|
|
||||||
verifyProperty(C, "y", {
|
|
||||||
value: "same_value",
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
assert(compareArray(x, ["a", "b", "c", "d"]));
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "y"), false);
|
|
||||||
|
|
||||||
assert(compareArray(x, ["a", "b", "c", "d"]), "static fields are not redefined on class instatiation");
|
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
static class fields forbid PropName 'constructor' (no early error for
|
|
||||||
ComputedPropertyName)
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
ComputedPropertyName : [ AssignmentExpression ]
|
|
||||||
Return empty.
|
|
||||||
|
|
||||||
// This test file also tests the ComputedPropertyName won't trigger the
|
|
||||||
// following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or
|
|
||||||
"constructor".
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var C = class {
|
|
||||||
static ["constructor"];
|
|
||||||
};
|
|
||||||
|
|
||||||
assert.sameValue(C.hasOwnProperty("constructor"), true);
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(c.hasOwnProperty("constructor"), false);
|
|
@ -1,58 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Cannot redefine a non-configurable, non-writable "prototype" property
|
|
||||||
esid: runtime-semantics-class-definition-evaluation
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
info: |
|
|
||||||
// This test file also tests the ComputedPropertyName won't trigger the
|
|
||||||
// following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or
|
|
||||||
"constructor".
|
|
||||||
|
|
||||||
2.13.2 Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
21. Perform MakeConstructor(F, false, proto).
|
|
||||||
...
|
|
||||||
25. Else, let elements be NonConstructorMethodDefinitions of ClassBody.
|
|
||||||
26. Let fieldRecords be a new empty List.
|
|
||||||
26. For each ClassElement me in order from elements
|
|
||||||
a. If IsStatic of me is false, then
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e
|
|
||||||
with arguments proto and false.
|
|
||||||
...
|
|
||||||
33. Let result be InitializeStaticFields(F).
|
|
||||||
...
|
|
||||||
|
|
||||||
// ClassElementEvaluation should evaluate the ComputedPropertyName
|
|
||||||
|
|
||||||
12.2.6.7 Runtime Semantics: Evaluation
|
|
||||||
|
|
||||||
ComputedPropertyName:[AssignmentExpression]
|
|
||||||
|
|
||||||
1. Let exprValue be the result of evaluating AssignmentExpression.
|
|
||||||
2. Let propName be ? GetValue(exprValue).
|
|
||||||
3. Return ? ToPropertyKey(propName).
|
|
||||||
|
|
||||||
// And the Static Fields should be defined to the class
|
|
||||||
|
|
||||||
2.8 InitializeStaticFields(F)
|
|
||||||
|
|
||||||
...
|
|
||||||
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
|
|
||||||
4. For each item fieldRecord in order from fieldRecords,
|
|
||||||
a. If fieldRecord.[[static]] is true, then
|
|
||||||
i. Perform ? DefineField(F, fieldRecord).
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
var C = class {
|
|
||||||
static ["prototype"];
|
|
||||||
};
|
|
||||||
});
|
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
static class fields forbid PropName 'constructor' (no early error for
|
|
||||||
ComputedPropertyName)
|
|
||||||
esid: sec-class-definitions-static-semantics-early-errors
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
info: |
|
|
||||||
Static Semantics: PropName
|
|
||||||
...
|
|
||||||
ComputedPropertyName : [ AssignmentExpression ]
|
|
||||||
Return empty.
|
|
||||||
|
|
||||||
// This test file also tests the ComputedPropertyName won't trigger the
|
|
||||||
// following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or
|
|
||||||
"constructor".
|
|
||||||
---*/
|
|
||||||
|
|
||||||
class C {
|
|
||||||
static ["constructor"];
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.sameValue(C.hasOwnProperty("constructor"), true);
|
|
||||||
|
|
||||||
var c = new C();
|
|
||||||
assert.sameValue(c.hasOwnProperty("constructor"), false);
|
|
@ -1,58 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
Cannot redefine a non-configurable, non-writable "prototype" property
|
|
||||||
esid: runtime-semantics-class-definition-evaluation
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
info: |
|
|
||||||
// This test file also tests the ComputedPropertyName won't trigger the
|
|
||||||
// following early error:
|
|
||||||
Static Semantics: Early Errors
|
|
||||||
|
|
||||||
ClassElement : staticFieldDefinition;
|
|
||||||
It is a Syntax Error if PropName of FieldDefinition is "prototype" or
|
|
||||||
"constructor".
|
|
||||||
|
|
||||||
2.13.2 Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
|
|
||||||
...
|
|
||||||
21. Perform MakeConstructor(F, false, proto).
|
|
||||||
...
|
|
||||||
25. Else, let elements be NonConstructorMethodDefinitions of ClassBody.
|
|
||||||
26. Let fieldRecords be a new empty List.
|
|
||||||
26. For each ClassElement me in order from elements
|
|
||||||
a. If IsStatic of me is false, then
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e
|
|
||||||
with arguments proto and false.
|
|
||||||
...
|
|
||||||
33. Let result be InitializeStaticFields(F).
|
|
||||||
...
|
|
||||||
|
|
||||||
// ClassElementEvaluation should evaluate the ComputedPropertyName
|
|
||||||
|
|
||||||
12.2.6.7 Runtime Semantics: Evaluation
|
|
||||||
|
|
||||||
ComputedPropertyName:[AssignmentExpression]
|
|
||||||
|
|
||||||
1. Let exprValue be the result of evaluating AssignmentExpression.
|
|
||||||
2. Let propName be ? GetValue(exprValue).
|
|
||||||
3. Return ? ToPropertyKey(propName).
|
|
||||||
|
|
||||||
// And the Static Fields should be defined to the class
|
|
||||||
|
|
||||||
2.8 InitializeStaticFields(F)
|
|
||||||
|
|
||||||
...
|
|
||||||
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
|
|
||||||
4. For each item fieldRecord in order from fieldRecords,
|
|
||||||
a. If fieldRecord.[[static]] is true, then
|
|
||||||
i. Perform ? DefineField(F, fieldRecord).
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
class C {
|
|
||||||
static ["prototype"];
|
|
||||||
};
|
|
||||||
});
|
|
@ -1,42 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Class definition should error if evaluation of static ClassElementName errors
|
|
||||||
esid: runtime-semantics-class-definition-evaluation
|
|
||||||
info: |
|
|
||||||
Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
...
|
|
||||||
27. For each ClassElement e in order from elements
|
|
||||||
a. If IsStatic of e is false, then
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
|
|
||||||
b. Else,
|
|
||||||
i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
|
|
||||||
c. If fields is an abrupt completion, then
|
|
||||||
i. Set the running execution context's LexicalEnvironment to lex.
|
|
||||||
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
|
|
||||||
iii. Return Completion(status).
|
|
||||||
|
|
||||||
Runtime Semantics: ClassElementEvaluation
|
|
||||||
...
|
|
||||||
ClassElement : static FieldDefinition ;
|
|
||||||
1. Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
|
|
||||||
|
|
||||||
Runtime Semantics: ClassFieldDefinitionEvaluation
|
|
||||||
With parameters isStatic and homeObject.
|
|
||||||
FieldDefinition : ClassElementNameInitializer
|
|
||||||
1. Let fieldName be the result of evaluating ClassElementName.
|
|
||||||
2. ReturnIfAbrupt(fieldName).
|
|
||||||
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
function f() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
class C {
|
|
||||||
static [f()]
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,42 +0,0 @@
|
|||||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: Class construction should error if evaluation of static field initializer errors
|
|
||||||
esid: runtime-semantics-class-definition-evaluation
|
|
||||||
info: |
|
|
||||||
Runtime Semantics: ClassDefinitionEvaluation
|
|
||||||
...
|
|
||||||
33. Let result be InitializeStaticFields(F).
|
|
||||||
34. If result is an abrupt completion, then
|
|
||||||
a. Set the running execution context's LexicalEnvironment to lex.
|
|
||||||
b. Return Completion(result).
|
|
||||||
|
|
||||||
InitializeStaticFields(F)
|
|
||||||
1. Assert: Type(F) is Object.
|
|
||||||
2. Assert: F is an ECMAScript function object.
|
|
||||||
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
|
|
||||||
4. For each item fieldRecord in order from fieldRecords,
|
|
||||||
a. If fieldRecord.[[static]] is true, then
|
|
||||||
i. Perform ? DefineField(F, fieldRecord).
|
|
||||||
|
|
||||||
DefineField(receiver, fieldRecord)
|
|
||||||
1. Assert: Type(receiver) is Object.
|
|
||||||
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
|
||||||
3. Let fieldName be fieldRecord.[[Name]].
|
|
||||||
4. Let initializer be fieldRecord.[[Initializer]].
|
|
||||||
5. If initializer is not empty, then
|
|
||||||
a. Let initValue be ? Call(initializer, receiver).
|
|
||||||
|
|
||||||
features: [class, class-fields-public]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
function f() {
|
|
||||||
throw new Test262Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
|
||||||
class C {
|
|
||||||
static x = f();
|
|
||||||
}
|
|
||||||
})
|
|
Loading…
x
Reference in New Issue
Block a user