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.
This commit is contained in:
Mike Pennisi 2018-11-12 00:03:00 -05:00
parent f9ffa71c56
commit 0ec9dbe3b3
12 changed files with 98 additions and 71 deletions

View File

@ -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();");
});

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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();

View File

@ -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();

View File

@ -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 linethrow new Test262Error();

View File

@ -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 linethrow new Test262Error();

View File

@ -4,9 +4,13 @@
/*--- /*---
info: Single line comments can not contain CARRIAGE RETURN (U+000D) inside info: Single line comments can not contain CARRIAGE RETURN (U+000D) inside
es5id: 7.3_A3.2_T2 es5id: 7.3_A3.2_T2
esid: sec-line-terminators
description: Insert CARRIAGE RETURN (\u000D) into begin of single line comment description: Insert CARRIAGE RETURN (\u000D) into begin of single line comment
negative:
phase: parse
type: SyntaxError
---*/ ---*/
assert.throws(SyntaxError, function() { $DONOTEVALUATE();
eval("//\u000D single line comment");
}); // this text is not included in the single-line comment that precedes it