Skip to content
Snippets Groups Projects
Commit 2488cb99 authored by Valerie R Young's avatar Valerie R Young Committed by Leo Balter
Browse files

classfields tests for eval early errors

# Conflicts:
#	src/class-fields/eval-err-contains-arguments.case
#	src/class-fields/eval-err-contains-supercall-1.case
#	src/class-fields/eval-err-contains-supercall-2.case
#	src/class-fields/eval-err-contains-supercall.case
#	src/class-fields/eval-err-contains-superproperty-1.case
#	src/class-fields/eval-err-contains-superproperty-2.case
parent ac5e65af
No related branches found
No related tags found
No related merge requests found
Showing
with 211 additions and 12 deletions
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: error if `new.call` in StatementList of eval
info: |
Additional Early Error Rules for Eval Inside Initializer
These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer.
ScriptBody : StatementList
...
The remaining eval rules apply as outside a constructor, inside a method, and inside a function.
Additional Early Error Rules for Eval Outside Functions
These static semantics are applied by PerformEval when a direct eval call occurs outside of any function.
ScriptBody:StatementList
It is a Syntax Error if StatementList Contains NewTarget.
features: [class, class-fields-public]
template: initializer-eval
---*/
//- initializer
new.call
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
...@@ -22,3 +22,8 @@ template: initializer-eval-super-call ...@@ -22,3 +22,8 @@ template: initializer-eval-super-call
//- initializer //- initializer
super()['x'] super()['x']
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
...@@ -4,21 +4,19 @@ ...@@ -4,21 +4,19 @@
/*--- /*---
desc: error if `super().x` in StatementList of eval desc: error if `super().x` in StatementList of eval
info: | info: |
Additional Early Error Rules for Eval Inside Initializer
These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer.
ScriptBody : StatementList
...
The remaining eval rules apply as outside a constructor, inside a method, and inside a function.
Additional Early Error Rules for Eval Outside Constructor Methods Additional Early Error Rules for Eval Outside Constructor Methods
These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression.
ScriptBody:StatementList ScriptBody:StatementList
It is a Syntax Error if StatementList Contains SuperCall. It is a Syntax Error if StatementList Contains SuperCall.
features: [class, class-fields-public] features: [class, class-fields-public]
template: initializer-eval-super-call template: initializer-eval-super-call
---*/ ---*/
//- initializer //- initializer
super().x super().x
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
...@@ -22,3 +22,7 @@ template: initializer-eval-super-call ...@@ -22,3 +22,7 @@ template: initializer-eval-super-call
//- initializer //- initializer
super() super()
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
...@@ -22,3 +22,7 @@ template: initializer-eval-super-property ...@@ -22,3 +22,7 @@ template: initializer-eval-super-property
//- initializer //- initializer
super.x super.x
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
...@@ -4,11 +4,6 @@ ...@@ -4,11 +4,6 @@
/*--- /*---
desc: error if `super['x']` in StatementList of eval desc: error if `super['x']` in StatementList of eval
info: | info: |
Additional Early Error Rules for Eval Inside Initializer
These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer.
ScriptBody : StatementList
...
The remaining eval rules apply as outside a constructor, inside a method, and inside a function. The remaining eval rules apply as outside a constructor, inside a method, and inside a function.
Additional Early Error Rules for Eval Outside Methods Additional Early Error Rules for Eval Outside Methods
...@@ -16,9 +11,14 @@ info: | ...@@ -16,9 +11,14 @@ info: |
ScriptBody:StatementList ScriptBody:StatementList
It is a Syntax Error if StatementList Contains SuperProperty. It is a Syntax Error if StatementList Contains SuperProperty.
features: [class, class-fields-public] features: [class, class-fields-public]
template: initializer-eval-super-property template: initializer-eval-super-property
---*/ ---*/
//- initializer //- initializer
super['x'] super['x']
//- earlyerror
SyntaxError
//- executionerror
SyntaxError
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/statements/class/fields-derived-cls-direct-
name: direct eval
---*/
class A = {}
var executed = false;
class C extends A = {
x = eval('executed = true; /*{ initializer }*/;';
}
assert.throws(/*{ earlyerror }*/, function() {
new C();
});
assert.sameValue(executed, false);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/statements/class/fields-derived-cls-indirect-
name: indirect eval
---*/
class A = {}
var executed = false;
class C extends A = {
x = (0, eval)('executed = true; /*{ initializer }*/;';
}
assert.throws(/*{ executionerror }*/, function() {
new C();
});
assert.sameValue(executed, true);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/expressions/class/fields-derived-cls-direct-
name: direct eval
---*/
A = class {}
var executed = false;
C = class extends A {
x = eval('executed = true; /*{ initializer }*/;';
}
assert.throws(/*{ earlyerror }*/, function() {
new C();
});
assert.sameValue(executed, false);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/expressions/class/fields-derived-cls-indirect-
name: indirect eval
---*/
A = class {}
var executed = false;
C = class extends A {
x = (0, eval)('executed = true; /*{ initializer }*/;';
}
assert.throws(/*{ executionerror }*/, function() {
new C();
});
assert.sameValue(executed, true);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/statements/class/fields-direct-
name: direct eval
---*/
var executed = false;
class C = {
x = eval('executed = true; /*{ initializer }*/;');
}
assert.throws(/*{ earlyerror }*/, function() {
new C();
});
assert.sameValue(executed, false);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/statements/class/fields-indirect-
name: indirect eval
---*/
var executed = false;
class C = {
x = (0, eval)('executed = true; /*{ initializer }*/;');
}
assert.throws(/*{ executionerror }*/, function() {
new C();
});
assert.sameValue(executed, true);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/expressions/class/fields-direct-
name: direct eval
---*/
var executed = false;
C = class {
x = eval('executed = true; /*{ initializer }*/;');
}
assert.throws(/*{ earlyerror }*/, function() {
new C();
});
assert.sameValue(executed, false);
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-performeval-rules-in-initializer
path: language/expressions/class/fields-indirect-
name: indirect eval
---*/
var executed = false;
C = class {
x = (0, eval)('executed = true; /*{ initializer }*/;');
}
assert.throws(/*{ executionerror }*/, function() {
new C();
});
assert.sameValue(executed, true);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment