From 0ec9dbe3b3a1562110b05fe92a4dc2142c7f0c4c Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Mon, 12 Nov 2018 00:03:00 -0500 Subject: [PATCH] Refactor LT tests for parsers: single-line comment The tests for the parsing of line terminators 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. Rename the files to make each test's purpose more clear. --- .../language/line-terminators/S7.3_A3.1_T1.js | 12 ---------- test/language/line-terminators/S7.3_A4_T2.js | 18 -------------- test/language/line-terminators/S7.3_A4_T3.js | 18 -------------- test/language/line-terminators/S7.3_A4_T4.js | 20 ---------------- .../line-terminators/comment-single-cr.js | 22 +++++++++++++++++ .../line-terminators/comment-single-lf.js | 23 ++++++++++++++++++ .../line-terminators/comment-single-ls.js | 22 +++++++++++++++++ .../line-terminators/comment-single-ps.js | 24 +++++++++++++++++++ ...3.2_T2.js => invalid-comment-single-cr.js} | 10 +++++--- ...3.1_T3.js => invalid-comment-single-lf.js} | 0 ...3.3_T1.js => invalid-comment-single-ls.js} | 0 ...3.4_T1.js => invalid-comment-single-ps.js} | 0 12 files changed, 98 insertions(+), 71 deletions(-) delete mode 100644 test/language/line-terminators/S7.3_A3.1_T1.js delete mode 100644 test/language/line-terminators/S7.3_A4_T2.js delete mode 100644 test/language/line-terminators/S7.3_A4_T3.js delete mode 100644 test/language/line-terminators/S7.3_A4_T4.js create mode 100644 test/language/line-terminators/comment-single-cr.js create mode 100644 test/language/line-terminators/comment-single-lf.js create mode 100644 test/language/line-terminators/comment-single-ls.js create mode 100644 test/language/line-terminators/comment-single-ps.js rename test/language/line-terminators/{S7.3_A3.2_T2.js => invalid-comment-single-cr.js} (65%) rename test/language/line-terminators/{S7.3_A3.1_T3.js => invalid-comment-single-lf.js} (100%) rename test/language/line-terminators/{S7.3_A3.3_T1.js => invalid-comment-single-ls.js} (100%) rename test/language/line-terminators/{S7.3_A3.4_T1.js => invalid-comment-single-ps.js} (100%) diff --git a/test/language/line-terminators/S7.3_A3.1_T1.js b/test/language/line-terminators/S7.3_A3.1_T1.js deleted file mode 100644 index 45ca9558f5..0000000000 --- a/test/language/line-terminators/S7.3_A3.1_T1.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Single line comments are terminated by the LINE FEED (U+000A) character -es5id: 7.3_A3.1_T1 -description: Insert LINE FEED (\u000A) into single line comment ----*/ - -assert.throws(Test262Error, function() { - eval("// single line \u000A throw new Test262Error();"); -}); diff --git a/test/language/line-terminators/S7.3_A4_T2.js b/test/language/line-terminators/S7.3_A4_T2.js deleted file mode 100644 index fc1d805d23..0000000000 --- a/test/language/line-terminators/S7.3_A4_T2.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Single line comments can contain Line Terminator at the end of line -es5id: 7.3_A4_T2 -description: Insert CARRIAGE RETURN (U+000D) into the end of single line comment ----*/ - -// CHECK#1 -eval("// single line comment\u000D"); - -// CHECK#2 -var x = 0; -eval("// single line comment\u000D x = 1;"); -if (x !== 1) { - $ERROR('#1: var x = 0; eval("// single line comment\\u000D x = 1;"); x === 1. Actual: ' + (x)); -} diff --git a/test/language/line-terminators/S7.3_A4_T3.js b/test/language/line-terminators/S7.3_A4_T3.js deleted file mode 100644 index 57b182938c..0000000000 --- a/test/language/line-terminators/S7.3_A4_T3.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Single line comments can contain Line Terminator at the end of line -es5id: 7.3_A4_T3 -description: Insert LINE SEPARATOR (U+2028) into the end of single line comment ----*/ - -// CHECK#1 -eval("// single line comment\u2028"); - -// CHECK#2 -var x = 0; -eval("// single line comment\u2028 x = 1;"); -if (x !== 1) { - $ERROR('#1: var x = 0; eval("// single line comment\\u2028 x = 1;"); x === 1. Actual: ' + (x)); -} diff --git a/test/language/line-terminators/S7.3_A4_T4.js b/test/language/line-terminators/S7.3_A4_T4.js deleted file mode 100644 index 9ebd1a4292..0000000000 --- a/test/language/line-terminators/S7.3_A4_T4.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Single line comments can contain Line Terminator at the end of line -es5id: 7.3_A4_T4 -description: > - Insert PARAGRAPH SEPARATOR (U+2029) into the end of single line - comment ----*/ - -// CHECK#1 -eval("// single line comment\u2029"); - -// CHECK#2 -var x = 0; -eval("// single line comment\u2029 x = 1;"); -if (x !== 1) { - $ERROR('#1: var x = 0; eval("// single line comment\\u2029 x = 1;"); x === 1. Actual: ' + (x)); -} diff --git a/test/language/line-terminators/comment-single-cr.js b/test/language/line-terminators/comment-single-cr.js new file mode 100644 index 0000000000..932ab27b4b --- /dev/null +++ b/test/language/line-terminators/comment-single-cr.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Single line comments can contain Line Terminator at the end of line +esid: sec-line-terminators +es5id: 7.3_A4_T2 +description: Insert CARRIAGE RETURN (U+000D) into the end of single line comment +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. + +// single line throw new Test262Error(); diff --git a/test/language/line-terminators/comment-single-lf.js b/test/language/line-terminators/comment-single-lf.js new file mode 100644 index 0000000000..0467a59920 --- /dev/null +++ b/test/language/line-terminators/comment-single-lf.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Single line comments are terminated by the LINE FEED (U+000A) character +esid: sec-line-terminators +es5id: 7.3_A3.1_T1 +description: Insert LINE FEED (\u000A) into single line comment +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. + +// single line +throw new Test262Error(); diff --git a/test/language/line-terminators/comment-single-ls.js b/test/language/line-terminators/comment-single-ls.js new file mode 100644 index 0000000000..e47731a09b --- /dev/null +++ b/test/language/line-terminators/comment-single-ls.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Single line comments can contain Line Terminator at the end of line +esid: sec-line-terminators +es5id: 7.3_A4_T3 +description: Insert LINE SEPARATOR (U+2028) into the end of single line comment +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. + +// single line
throw new Test262Error(); diff --git a/test/language/line-terminators/comment-single-ps.js b/test/language/line-terminators/comment-single-ps.js new file mode 100644 index 0000000000..95e6ec02e3 --- /dev/null +++ b/test/language/line-terminators/comment-single-ps.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Single line comments can contain Line Terminator at the end of line +esid: sec-line-terminators +es5id: 7.3_A4_T4 +description: > + Insert PARAGRAPH SEPARATOR (U+2029) into the end of single line + comment +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. + +// single line
throw new Test262Error(); diff --git a/test/language/line-terminators/S7.3_A3.2_T2.js b/test/language/line-terminators/invalid-comment-single-cr.js similarity index 65% rename from test/language/line-terminators/S7.3_A3.2_T2.js rename to test/language/line-terminators/invalid-comment-single-cr.js index 580e558a1b..09568f1a64 100644 --- a/test/language/line-terminators/S7.3_A3.2_T2.js +++ b/test/language/line-terminators/invalid-comment-single-cr.js @@ -4,9 +4,13 @@ /*--- info: Single line comments can not contain CARRIAGE RETURN (U+000D) inside es5id: 7.3_A3.2_T2 +esid: sec-line-terminators description: Insert CARRIAGE RETURN (\u000D) into begin of single line comment +negative: + phase: parse + type: SyntaxError ---*/ -assert.throws(SyntaxError, function() { - eval("//\u000D single line comment"); -}); +$DONOTEVALUATE(); + +// this text is not included in the single-line comment that precedes it diff --git a/test/language/line-terminators/S7.3_A3.1_T3.js b/test/language/line-terminators/invalid-comment-single-lf.js similarity index 100% rename from test/language/line-terminators/S7.3_A3.1_T3.js rename to test/language/line-terminators/invalid-comment-single-lf.js diff --git a/test/language/line-terminators/S7.3_A3.3_T1.js b/test/language/line-terminators/invalid-comment-single-ls.js similarity index 100% rename from test/language/line-terminators/S7.3_A3.3_T1.js rename to test/language/line-terminators/invalid-comment-single-ls.js diff --git a/test/language/line-terminators/S7.3_A3.4_T1.js b/test/language/line-terminators/invalid-comment-single-ps.js similarity index 100% rename from test/language/line-terminators/S7.3_A3.4_T1.js rename to test/language/line-terminators/invalid-comment-single-ps.js -- GitLab