Split up indirect and direct eval cases

This commit is contained in:
Rick Waldron 2020-10-14 13:59:54 -04:00
parent bab4da88e3
commit 0e77b43c9b
22 changed files with 60 additions and 62 deletions

View File

@ -0,0 +1,16 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: No error if `arguments` in StatementList of eval
info: |
For indirect eval, the "Additional Early Error Rules for Eval Inside Initializer"
(in #sec-performeval-rules-in-initializer) are NOT applicable.
features: [class, class-fields-public]
template: initializer-indirect-eval-arguments
---*/
//- initializer
arguments
//- arrow-body
() => arguments

View File

@ -18,7 +18,7 @@ info: |
... ...
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
features: [class, class-fields-public] features: [class, class-fields-public]
template: initializer-eval-arguments template: initializer-direct-eval-arguments
---*/ ---*/
//- initializer //- initializer
@ -27,5 +27,3 @@ arguments
() => arguments () => arguments
//- earlyerror //- earlyerror
SyntaxError SyntaxError
//- executionerror
ReferenceError

View File

@ -6,18 +6,14 @@ esid: sec-performeval-rules-in-initializer
path: language/statements/class/elements/nested-indirect- path: language/statements/class/elements/nested-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-public] features: [class, class-fields-public]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
class C { class C {
x = () => { x = () => {
var t = () => { (0, eval)('executed = true; /*{ initializer }*/;'); }; var t = () => (0, eval)('/*{ initializer }*/;');
t(); return t();
} }
} }
assert.sameValue(new C().x(), /*{ initializer }*/);
assert.throws(/*{ executionerror }*/, function() {
new C().x();
});
assert.sameValue(executed, false);

View File

@ -6,15 +6,12 @@ esid: sec-performeval-rules-in-initializer
path: language/statements/class/elements/indirect- path: language/statements/class/elements/indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-public] features: [class, class-fields-public]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
class C { class C {
x = (0, eval)('executed = true; /*{ initializer }*/;'); x = (0, eval)('/*{ initializer }*/;');
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x, /*{ initializer }*/);
new C();
});
assert.sameValue(executed, true);

View File

@ -6,15 +6,15 @@ esid: sec-performeval-rules-in-initializer
path: language/statements/class/elements/nested-private-indirect- path: language/statements/class/elements/nested-private-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-private] features: [class, class-fields-private]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
class C { class C {
#x = (0, eval)('executed = true; /*{ initializer }*/;'); #x = (0, eval)('/*{ initializer }*/;');
x() {
return this.#x;
}
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x(), /*{ initializer }*/);
new C();
});
assert.sameValue(executed, true);

View File

@ -6,15 +6,14 @@ esid: sec-performeval-rules-in-initializer
path: language/statements/class/elements/private-indirect- path: language/statements/class/elements/private-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-private] features: [class, class-fields-private]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
class C { class C {
#x = (0, eval)('executed = true; /*{ initializer }*/;'); #x = (0, eval)('/*{ initializer }*/;');
x() {
return this.#x;
}
} }
assert.sameValue(new C().x(), /*{ initializer }*/);
assert.throws(/*{ executionerror }*/, function() {
new C();
});
assert.sameValue(executed, true);

View File

@ -6,15 +6,12 @@ esid: sec-performeval-rules-in-initializer
path: language/expressions/class/elements/nested-indirect- path: language/expressions/class/elements/nested-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-public] features: [class, class-fields-public]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
var C = class { var C = class {
x = () => (0, eval)('executed = true; /*{ initializer }*/;'); x = () => (0, eval)('/*{ initializer }*/;');
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x(), /*{ initializer }*/);
new C().x();
});
assert.sameValue(executed, true);

View File

@ -6,15 +6,13 @@ esid: sec-performeval-rules-in-initializer
path: language/expressions/class/elements/indirect- path: language/expressions/class/elements/indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-public] features: [class, class-fields-public]
flags: [noStrict]
---*/ ---*/
var /*{ initializer }*/ = 1;
var executed = false; var executed = false;
var C = class { var C = class {
x = (0, eval)('executed = true; /*{ initializer }*/;'); x = (0, eval)('/*{ initializer }*/;');
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x, /*{ initializer }*/);
new C();
});
assert.sameValue(executed, true);

View File

@ -6,18 +6,15 @@ esid: sec-performeval-rules-in-initializer
path: language/expressions/class/elements/nested-private-indirect- path: language/expressions/class/elements/nested-private-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-private] features: [class, class-fields-private]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
var C = class { var C = class {
#x = () => (0, eval)('executed = true; /*{ initializer }*/;'); #x = () => (0, eval)('/*{ initializer }*/;');
x() { x() {
this.#x(); return this.#x();
} }
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x(), /*{ initializer }*/);
new C().x();
});
assert.sameValue(executed, true);

View File

@ -6,15 +6,15 @@ esid: sec-performeval-rules-in-initializer
path: language/expressions/class/elements/private-indirect- path: language/expressions/class/elements/private-indirect-
name: indirect eval name: indirect eval
features: [class, class-fields-private] features: [class, class-fields-private]
flags: [noStrict]
---*/ ---*/
var executed = false; var /*{ initializer }*/ = 1;
var C = class { var C = class {
#x = (0, eval)('executed = true; /*{ initializer }*/;'); #x = (0, eval)('/*{ initializer }*/;');
x() {
return this.#x;
}
} }
assert.throws(/*{ executionerror }*/, function() { assert.sameValue(new C().x(), /*{ initializer }*/);
new C();
});
assert.sameValue(executed, true);