From ceb79988ae7c6b0b2c52a141af4063655e2e002a Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Sun, 23 Sep 2018 21:32:15 -0400 Subject: [PATCH] Relocate and refactor tests The tests for the parsing of `for/in` loops were expressed using eval. This made the tests more complex than necessary and also prevented the tests from providing value to ECMAScript parsers. Remove the use of eval and instead express the expectations with literal source text. Move the tests to the `for-in` directory to better reflect the grammar production that they test. --- .../var-arguments-strict-init.js} | 10 ++++++---- .../12.2.1-36-s.js => for-in/var-arguments-strict.js} | 10 ++++++---- .../12.2.1-35-s.js => for-in/var-eval-strict-init.js} | 10 ++++++---- .../12.2.1-34-s.js => for-in/var-eval-strict.js} | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) rename test/language/statements/{variable/12.2.1-37-s.js => for-in/var-arguments-strict-init.js} (62%) rename test/language/statements/{variable/12.2.1-36-s.js => for-in/var-arguments-strict.js} (61%) rename test/language/statements/{variable/12.2.1-35-s.js => for-in/var-eval-strict-init.js} (61%) rename test/language/statements/{variable/12.2.1-34-s.js => for-in/var-eval-strict.js} (61%) diff --git a/test/language/statements/variable/12.2.1-37-s.js b/test/language/statements/for-in/var-arguments-strict-init.js similarity index 62% rename from test/language/statements/variable/12.2.1-37-s.js rename to test/language/statements/for-in/var-arguments-strict-init.js index cf7227e630..b46aed9d31 100644 --- a/test/language/statements/variable/12.2.1-37-s.js +++ b/test/language/statements/for-in/var-arguments-strict-init.js @@ -2,14 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es5id: 12.2.1-37-s +esid: sec-for-statement description: > 'for(var arguments = 42 in ...) {...}' throws SyntaxError in strict mode flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval('for (var arguments = 42 in null) {};'); -}); +for (var arguments = 42 in null) {} diff --git a/test/language/statements/variable/12.2.1-36-s.js b/test/language/statements/for-in/var-arguments-strict.js similarity index 61% rename from test/language/statements/variable/12.2.1-36-s.js rename to test/language/statements/for-in/var-arguments-strict.js index 872d7c7c2a..973ecafe5b 100644 --- a/test/language/statements/variable/12.2.1-36-s.js +++ b/test/language/statements/for-in/var-arguments-strict.js @@ -2,12 +2,14 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es5id: 12.2.1-36-s +esid: sec-for-statement description: "'for(var arguments in ...) {...}' throws SyntaxError in strict mode" flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval('for (var arguments in null) {};'); -}); +for (var arguments in null) {} diff --git a/test/language/statements/variable/12.2.1-35-s.js b/test/language/statements/for-in/var-eval-strict-init.js similarity index 61% rename from test/language/statements/variable/12.2.1-35-s.js rename to test/language/statements/for-in/var-eval-strict-init.js index 5d8d17ce55..efdba55afd 100644 --- a/test/language/statements/variable/12.2.1-35-s.js +++ b/test/language/statements/for-in/var-eval-strict-init.js @@ -2,12 +2,14 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es5id: 12.2.1-35-s +esid: sec-for-statement description: "'for(var eval = 42 in ...) {...}' throws SyntaxError in strict mode" flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval('for (var eval = 42 in null) {};'); -}); +for (var eval = 42 in null) {} diff --git a/test/language/statements/variable/12.2.1-34-s.js b/test/language/statements/for-in/var-eval-strict.js similarity index 61% rename from test/language/statements/variable/12.2.1-34-s.js rename to test/language/statements/for-in/var-eval-strict.js index c7794514a1..114add8d1f 100644 --- a/test/language/statements/variable/12.2.1-34-s.js +++ b/test/language/statements/for-in/var-eval-strict.js @@ -2,12 +2,14 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es5id: 12.2.1-34-s +esid: sec-for-statement description: "'for(var eval in ...) {...}' throws SyntaxError in strict mode" flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval('for (var eval in null) {};'); -}); +for (var eval in null) {}