diff options
author | André Bargull <andre.bargull@gmail.com> | 2017-11-01 07:54:10 -0700 |
---|---|---|
committer | André Bargull <andre.bargull@gmail.com> | 2017-11-01 08:23:43 -0700 |
commit | 5ec3bd7d03d8203c8235c964165b768349f1d4a4 (patch) | |
tree | 2a0aa0161de8c2007b3a4c1210f2d995cce8f2f3 /src | |
parent | 2d6a356699eb9067cb38dd742da09d8824363abe (diff) | |
download | qtdeclarative-testsuites-5ec3bd7d03d8203c8235c964165b768349f1d4a4.tar.gz |
Fix more issues in eval tests for class-fields
Changes:
- Changed eval-err-contains-supercall-1.case to add a property access similar to eval-err-contains-supercall-2.case, without this property access eval-err-contains-supercall-1.case would be identical to eval-err-contains-supercall.case.
- Remove unnecessary "earlyerror" and "executionerror" template arguments when the value is already clear from the context.
- Fixed the description in eval-err-contains-supercall-2.case to refer to the correct early error rule.
- Fixed a copy-paste error in eval-err-contains-superproperty-1.case and eval-err-contains-superproperty-2.case.
- Split initializer-eval-super into initializer-eval-super-call and initializer-eval-super-property, because we actually need to test different behaviour for the super-call compared to the super-property case.
- Split initializer-eval into initializer-eval-arguments and initializer-eval-newtarget, because `arguments` and `new.target` are differently handled in class-fields.
- And fixed other copy-paste errors in the template files.
Fixes #1325
Diffstat (limited to 'src')
23 files changed, 181 insertions, 51 deletions
diff --git a/src/class-fields/eval-err-contains-arguments.case b/src/class-fields/eval-err-contains-arguments.case index 7cf7fd2c6..f9a6f6345 100644 --- a/src/class-fields/eval-err-contains-arguments.case +++ b/src/class-fields/eval-err-contains-arguments.case @@ -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. features: [class-fields] -template: initializer-eval +template: initializer-eval-arguments ---*/ //- initializer diff --git a/src/class-fields/eval-err-contains-newcall.case b/src/class-fields/eval-err-contains-newtarget.case index 3b8eed5bc..65ab504e4 100644 --- a/src/class-fields/eval-err-contains-newcall.case +++ b/src/class-fields/eval-err-contains-newtarget.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -desc: error if `new.call` in StatementList of eval +desc: error if `new.target` 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. @@ -17,12 +17,8 @@ info: | It is a Syntax Error if StatementList Contains NewTarget. features: [class-fields] -template: initializer-eval +template: initializer-eval-newtarget ---*/ //- initializer -new.call -//- earlyerror -SyntaxError -//- executionerror -SyntaxError +new.target diff --git a/src/class-fields/eval-err-contains-supercall-1.case b/src/class-fields/eval-err-contains-supercall-1.case index eaabad6eb..7be53f942 100644 --- a/src/class-fields/eval-err-contains-supercall-1.case +++ b/src/class-fields/eval-err-contains-supercall-1.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -desc: error if `super()` in StatementList of eval +desc: error if `super()['x']` 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. @@ -17,12 +17,8 @@ info: | It is a Syntax Error if StatementList Contains SuperCall. features: [class-fields] -template: initializer-eval-super +template: initializer-eval-super-call ---*/ //- initializer -super() -//- earlyerror -SyntaxError -//- executionerror -SyntaxError +super()['x'] diff --git a/src/class-fields/eval-err-contains-supercall-2.case b/src/class-fields/eval-err-contains-supercall-2.case index 45166f164..d0c9e3449 100644 --- a/src/class-fields/eval-err-contains-supercall-2.case +++ b/src/class-fields/eval-err-contains-supercall-2.case @@ -11,18 +11,14 @@ info: | ... The remaining eval rules apply as outside a constructor, inside a method, and inside a function. - Additional Early Error Rules for Eval Outside Methods - These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + 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. ScriptBody:StatementList It is a Syntax Error if StatementList Contains SuperCall. features: [class-fields] -template: initializer-eval-super +template: initializer-eval-super-call ---*/ //- initializer super().x -//- earlyerror -SyntaxError -//- executionerror -SyntaxError diff --git a/src/class-fields/eval-err-contains-supercall.case b/src/class-fields/eval-err-contains-supercall.case index eaabad6eb..b6370bc13 100644 --- a/src/class-fields/eval-err-contains-supercall.case +++ b/src/class-fields/eval-err-contains-supercall.case @@ -17,12 +17,8 @@ info: | It is a Syntax Error if StatementList Contains SuperCall. features: [class-fields] -template: initializer-eval-super +template: initializer-eval-super-call ---*/ //- initializer super() -//- earlyerror -SyntaxError -//- executionerror -SyntaxError diff --git a/src/class-fields/eval-err-contains-superproperty-1.case b/src/class-fields/eval-err-contains-superproperty-1.case index 7af5c8144..0d9a2d3a5 100644 --- a/src/class-fields/eval-err-contains-superproperty-1.case +++ b/src/class-fields/eval-err-contains-superproperty-1.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -desc: error if `super().x` in StatementList of eval +desc: error if `super.x` 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. @@ -17,12 +17,8 @@ info: | It is a Syntax Error if StatementList Contains SuperProperty. features: [class-fields] -template: initializer-eval-super +template: initializer-eval-super-property ---*/ //- initializer super.x -//- earlyerror -SyntaxError -//- executionerror -SyntaxError diff --git a/src/class-fields/eval-err-contains-superproperty-2.case b/src/class-fields/eval-err-contains-superproperty-2.case index 21a3db544..7840bdb77 100644 --- a/src/class-fields/eval-err-contains-superproperty-2.case +++ b/src/class-fields/eval-err-contains-superproperty-2.case @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -desc: error if `super().x` in StatementList of eval +desc: error if `super['x']` 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. @@ -17,12 +17,8 @@ info: | It is a Syntax Error if StatementList Contains SuperProperty. features: [class-fields] -template: initializer-eval-super +template: initializer-eval-super-property ---*/ //- initializer super['x'] -//- earlyerror -SyntaxError -//- executionerror -SyntaxError diff --git a/src/class-fields/initializer-eval/cls-decl-fields-eval.template b/src/class-fields/initializer-eval-arguments/cls-decl-fields-eval.template index ed721afeb..f75aa39e0 100644 --- a/src/class-fields/initializer-eval/cls-decl-fields-eval.template +++ b/src/class-fields/initializer-eval-arguments/cls-decl-fields-eval.template @@ -8,7 +8,7 @@ name: direct eval ---*/ var executed = false; -class C = { +class C { x = eval('executed = true; /*{ initializer }*/;'); } diff --git a/src/class-fields/initializer-eval/cls-decl-fields-indirect-eval.template b/src/class-fields/initializer-eval-arguments/cls-decl-fields-indirect-eval.template index 11aa34d0d..0b795b6e7 100644 --- a/src/class-fields/initializer-eval/cls-decl-fields-indirect-eval.template +++ b/src/class-fields/initializer-eval-arguments/cls-decl-fields-indirect-eval.template @@ -8,7 +8,7 @@ name: indirect eval ---*/ var executed = false; -class C = { +class C { x = (0, eval)('executed = true; /*{ initializer }*/;'); } diff --git a/src/class-fields/initializer-eval/cls-expr-fields-eval.template b/src/class-fields/initializer-eval-arguments/cls-expr-fields-eval.template index a8acc6317..a8acc6317 100644 --- a/src/class-fields/initializer-eval/cls-expr-fields-eval.template +++ b/src/class-fields/initializer-eval-arguments/cls-expr-fields-eval.template diff --git a/src/class-fields/initializer-eval/cls-expr-fields-indirect-eval.template b/src/class-fields/initializer-eval-arguments/cls-expr-fields-indirect-eval.template index 8a37149a3..8a37149a3 100644 --- a/src/class-fields/initializer-eval/cls-expr-fields-indirect-eval.template +++ b/src/class-fields/initializer-eval-arguments/cls-expr-fields-indirect-eval.template diff --git a/src/class-fields/initializer-eval-newtarget/cls-decl-fields-eval.template b/src/class-fields/initializer-eval-newtarget/cls-decl-fields-eval.template new file mode 100644 index 000000000..8ef1ea4d3 --- /dev/null +++ b/src/class-fields/initializer-eval-newtarget/cls-decl-fields-eval.template @@ -0,0 +1,18 @@ +// 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 }*/;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); diff --git a/src/class-fields/initializer-eval-newtarget/cls-decl-fields-indirect-eval.template b/src/class-fields/initializer-eval-newtarget/cls-decl-fields-indirect-eval.template new file mode 100644 index 000000000..ee4630ca1 --- /dev/null +++ b/src/class-fields/initializer-eval-newtarget/cls-decl-fields-indirect-eval.template @@ -0,0 +1,19 @@ +// 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(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); diff --git a/src/class-fields/initializer-eval-newtarget/cls-expr-fields-eval.template b/src/class-fields/initializer-eval-newtarget/cls-expr-fields-eval.template new file mode 100644 index 000000000..1c6b4b438 --- /dev/null +++ b/src/class-fields/initializer-eval-newtarget/cls-expr-fields-eval.template @@ -0,0 +1,18 @@ +// 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; +var C = class { + x = eval('executed = true; /*{ initializer }*/;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); diff --git a/src/class-fields/initializer-eval-newtarget/cls-expr-fields-indirect-eval.template b/src/class-fields/initializer-eval-newtarget/cls-expr-fields-indirect-eval.template new file mode 100644 index 000000000..1c8bbf597 --- /dev/null +++ b/src/class-fields/initializer-eval-newtarget/cls-expr-fields-indirect-eval.template @@ -0,0 +1,19 @@ +// 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; +var C = class { + x = (0, eval)('executed = true; /*{ initializer }*/;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); diff --git a/src/class-fields/initializer-eval-super/cls-decl-fields-eval.template b/src/class-fields/initializer-eval-super-call/cls-decl-fields-eval.template index 5870c9a69..8ec98eac9 100644 --- a/src/class-fields/initializer-eval-super/cls-decl-fields-eval.template +++ b/src/class-fields/initializer-eval-super-call/cls-decl-fields-eval.template @@ -7,14 +7,14 @@ path: language/statements/class/fields-derived-cls-direct- name: direct eval ---*/ -class A = {} +class A {} var executed = false; -class C extends A = { +class C extends A { x = eval('executed = true; /*{ initializer }*/;'); } -assert.throws(/*{ earlyerror }*/, function() { +assert.throws(SyntaxError, function() { new C(); }); diff --git a/src/class-fields/initializer-eval-super/cls-decl-fields-indirect-eval.template b/src/class-fields/initializer-eval-super-call/cls-decl-fields-indirect-eval.template index 9dafcc047..0f9a97c6e 100644 --- a/src/class-fields/initializer-eval-super/cls-decl-fields-indirect-eval.template +++ b/src/class-fields/initializer-eval-super-call/cls-decl-fields-indirect-eval.template @@ -7,15 +7,15 @@ path: language/statements/class/fields-derived-cls-indirect- name: indirect eval ---*/ -class A = {} +class A {} var executed = false; -class C extends A = { +class C extends A { x = (0, eval)('executed = true; /*{ initializer }*/;'); } -assert.throws(/*{ executionerror }*/, function() { +assert.throws(SyntaxError, function() { new C(); }); -assert.sameValue(executed, true); +assert.sameValue(executed, false); diff --git a/src/class-fields/initializer-eval-super/cls-expr-fields-eval.template b/src/class-fields/initializer-eval-super-call/cls-expr-fields-eval.template index d4517cd61..65ab9d8db 100644 --- a/src/class-fields/initializer-eval-super/cls-expr-fields-eval.template +++ b/src/class-fields/initializer-eval-super-call/cls-expr-fields-eval.template @@ -14,7 +14,7 @@ var C = class extends A { x = eval('executed = true; /*{ initializer }*/;'); } -assert.throws(/*{ earlyerror }*/, function() { +assert.throws(SyntaxError, function() { new C(); }); diff --git a/src/class-fields/initializer-eval-super/cls-expr-fields-indirect-eval.template b/src/class-fields/initializer-eval-super-call/cls-expr-fields-indirect-eval.template index f024c4f07..83415b3df 100644 --- a/src/class-fields/initializer-eval-super/cls-expr-fields-indirect-eval.template +++ b/src/class-fields/initializer-eval-super-call/cls-expr-fields-indirect-eval.template @@ -14,8 +14,8 @@ var C = class extends A { x = (0, eval)('executed = true; /*{ initializer }*/;'); } -assert.throws(/*{ executionerror }*/, function() { +assert.throws(SyntaxError, function() { new C(); }); -assert.sameValue(executed, true); +assert.sameValue(executed, false); diff --git a/src/class-fields/initializer-eval-super-property/cls-decl-fields-eval.template b/src/class-fields/initializer-eval-super-property/cls-decl-fields-eval.template new file mode 100644 index 000000000..a994b1e45 --- /dev/null +++ b/src/class-fields/initializer-eval-super-property/cls-decl-fields-eval.template @@ -0,0 +1,19 @@ +// 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 }*/;'); +} + +new C(); + +assert.sameValue(executed, true); diff --git a/src/class-fields/initializer-eval-super-property/cls-decl-fields-indirect-eval.template b/src/class-fields/initializer-eval-super-property/cls-decl-fields-indirect-eval.template new file mode 100644 index 000000000..0f9a97c6e --- /dev/null +++ b/src/class-fields/initializer-eval-super-property/cls-decl-fields-indirect-eval.template @@ -0,0 +1,21 @@ +// 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(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); diff --git a/src/class-fields/initializer-eval-super-property/cls-expr-fields-eval.template b/src/class-fields/initializer-eval-super-property/cls-expr-fields-eval.template new file mode 100644 index 000000000..b7ca546be --- /dev/null +++ b/src/class-fields/initializer-eval-super-property/cls-expr-fields-eval.template @@ -0,0 +1,19 @@ +// 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 +---*/ + +var A = class {} + +var executed = false; +var C = class extends A { + x = eval('executed = true; /*{ initializer }*/;'); +} + +new C(); + +assert.sameValue(executed, true); diff --git a/src/class-fields/initializer-eval-super-property/cls-expr-fields-indirect-eval.template b/src/class-fields/initializer-eval-super-property/cls-expr-fields-indirect-eval.template new file mode 100644 index 000000000..83415b3df --- /dev/null +++ b/src/class-fields/initializer-eval-super-property/cls-expr-fields-indirect-eval.template @@ -0,0 +1,21 @@ +// 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 +---*/ + +var A = class {} + +var executed = false; +var C = class extends A { + x = (0, eval)('executed = true; /*{ initializer }*/;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); |