From 6b49b770d86b723f26230a1ae0fe6af0ea86d57f Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Tue, 1 Jan 2019 11:44:28 -0500 Subject: [PATCH] Refactor LT tests for parsers: token delimiters 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. --- test/language/line-terminators/S7.3_A1.3.js | 22 ------------------- test/language/line-terminators/S7.3_A1.4.js | 22 ------------------- .../{S7.3_A1.1_T2.js => between-tokens-lf.js} | 7 +++--- .../line-terminators/between-tokens-ls.js | 13 +++++++++++ .../line-terminators/between-tokens-ps.js | 13 +++++++++++ 5 files changed, 29 insertions(+), 48 deletions(-) delete mode 100644 test/language/line-terminators/S7.3_A1.3.js delete mode 100644 test/language/line-terminators/S7.3_A1.4.js rename test/language/line-terminators/{S7.3_A1.1_T2.js => between-tokens-lf.js} (77%) create mode 100644 test/language/line-terminators/between-tokens-ls.js create mode 100644 test/language/line-terminators/between-tokens-ps.js diff --git a/test/language/line-terminators/S7.3_A1.3.js b/test/language/line-terminators/S7.3_A1.3.js deleted file mode 100644 index f8073d8757..0000000000 --- a/test/language/line-terminators/S7.3_A1.3.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: LINE SEPARATOR (U+2028) may occur between any two tokens -es5id: 7.3_A1.3 -description: Insert LINE SEPARATOR (\u2028) between tokens of var x=1 ----*/ - -var result; - -// CHECK#1 -eval("\u2028var\u2028x\u2028=\u20281\u2028; result = x;"); -if (result !== 1) { - $ERROR('#1: eval("\\u2028var\\u2028x\\u2028=\\u20281\\u2028"); result === 1. Actual: ' + (result)); -} - -//CHECK#2 -eval("\u2028" + "var" + "\u2028" + "x" + "\u2028" + "=" + "\u2028" + "2" + "\u2028; result = x;"); -if (result !== 2) { - $ERROR('#2: eval("\\u2028" + "var" + "\\u2028" + "x" + "\\u2028" + "=" + "\\u2028" + "2" + "\\u2028"); result === 2. Actual: ' + (result)); -} diff --git a/test/language/line-terminators/S7.3_A1.4.js b/test/language/line-terminators/S7.3_A1.4.js deleted file mode 100644 index d137ba2dfc..0000000000 --- a/test/language/line-terminators/S7.3_A1.4.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: PARAGRAPH SEPARATOR (U+2029) may occur between any two tokens -es5id: 7.3_A1.4 -description: Insert PARAGRAPH SEPARATOR (\u2029) between tokens of var x=1 ----*/ - -var result; - -// CHECK#1 -eval("\u2029var\u2029x\u2029=\u20291\u2029; result = x;"); -if (result !== 1) { - $ERROR('#1: eval("\\u2029var\\u2029x\\u2029=\\u20291\\u2029"); result === 1. Actual: ' + (result)); -} - -//CHECK#2 -eval("\u2029" + "var" + "\u2029" + "x" + "\u2029" + "=" + "\u2029" + "2" + "\u2029; result = x;"); -if (result !== 2) { - $ERROR('#2: eval("\\u2029" + "var" + "\\u2029" + "x" + "\\u2029" + "=" + "\\u2029" + "2" + "\\u2029"); result === 2. Actual: ' + (result)); -} diff --git a/test/language/line-terminators/S7.3_A1.1_T2.js b/test/language/line-terminators/between-tokens-lf.js similarity index 77% rename from test/language/line-terminators/S7.3_A1.1_T2.js rename to test/language/line-terminators/between-tokens-lf.js index e097f41fcc..e3081d0f76 100644 --- a/test/language/line-terminators/S7.3_A1.1_T2.js +++ b/test/language/line-terminators/between-tokens-lf.js @@ -3,15 +3,14 @@ /*--- info: LINE FEED (U+000A) may occur between any two tokens +esid: sec-line-terminators es5id: 7.3_A1.1_T2 description: Insert real LINE FEED between tokens of var x=1 ---*/ -//CHECK#1 var x = 1; -if (x !== 1) { - $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); -} + +assert.sameValue(x, 1); diff --git a/test/language/line-terminators/between-tokens-ls.js b/test/language/line-terminators/between-tokens-ls.js new file mode 100644 index 0000000000..1d338eb1ba --- /dev/null +++ b/test/language/line-terminators/between-tokens-ls.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: LINE SEPARATOR (U+2028) may occur between any two tokens +esid: sec-line-terminators +es5id: 7.3_A1.3 +description: Insert LINE SEPARATOR (\u2028) between tokens of var x=1 +---*/ + +var
x
=
1
; + +assert.sameValue(x, 1); diff --git a/test/language/line-terminators/between-tokens-ps.js b/test/language/line-terminators/between-tokens-ps.js new file mode 100644 index 0000000000..0451419ced --- /dev/null +++ b/test/language/line-terminators/between-tokens-ps.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: PARAGRAPH SEPARATOR (U+2029) may occur between any two tokens +esid: sec-line-terminators +es5id: 7.3_A1.4 +description: Insert PARAGRAPH SEPARATOR (\u2029) between tokens of var x=1 +---*/ + +var
x
=
1
; + +assert.sameValue(x, 1); -- GitLab