From db8ff7cc01a111b5cd7940537de075fe747a2b39 Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Mon, 9 May 2016 18:29:18 -0400 Subject: [PATCH] Add tests for Annex B extns to comments (#612) --- .../comments/multi-line-html-close.js | 58 +++++++++++++++++++ .../comments/single-line-html-close-asi.js | 37 ++++++++++++ .../comments/single-line-html-close.js | 48 +++++++++++++++ .../comments/single-line-html-open.js | 42 ++++++++++++++ .../comments/multi-line-html-close-extra.js | 22 +++++++ .../single-line-html-close-without-lt.js | 20 +++++++ .../comment-multi-line-html-close.js | 14 +++++ .../comment-single-line-html-close.js | 13 +++++ .../comment-single-line-html-open.js | 13 +++++ 9 files changed, 267 insertions(+) create mode 100644 test/annexB/language/comments/multi-line-html-close.js create mode 100644 test/annexB/language/comments/single-line-html-close-asi.js create mode 100644 test/annexB/language/comments/single-line-html-close.js create mode 100644 test/annexB/language/comments/single-line-html-open.js create mode 100644 test/language/comments/multi-line-html-close-extra.js create mode 100644 test/language/comments/single-line-html-close-without-lt.js create mode 100644 test/language/module-code/comment-multi-line-html-close.js create mode 100644 test/language/module-code/comment-single-line-html-close.js create mode 100644 test/language/module-code/comment-single-line-html-open.js diff --git a/test/annexB/language/comments/multi-line-html-close.js b/test/annexB/language/comments/multi-line-html-close.js new file mode 100644 index 0000000000..8e307f5945 --- /dev/null +++ b/test/annexB/language/comments/multi-line-html-close.js @@ -0,0 +1,58 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +es6id: B1.3 +description: Optional HTMLCloseComment following MultiLineComment +info: | + Comment :: + MultiLineComment + SingleLineComment + SingleLineHTMLOpenComment + SingleLineHTMLCloseComment + SingleLineDelimitedComment + + MultiLineComment :: + /* FirstCommentLine[opt] LineTerminator MultiLineCommentChars[opt] * / HTMLCloseComment[opt] + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: Test262Error +---*/ + +var counter = 0; +/* +*/--> +counter += 1; + +/* +*/-->the comment extends to these characters +counter += 1; + +/* optional FirstCommentLine +*/-->the comment extends to these characters +counter += 1; + +/* +optional +MultiLineCommentChars */-->the comment extends to these characters +counter += 1; + +/* +*/ /* optional SingleLineDelimitedCommentSequence */-->the comment extends to these characters +counter += 1; + +/* +*/ /**/ /* second optional SingleLineDelimitedCommentSequence */-->the comment extends to these characters +counter += 1; + +// 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. +if (counter === 6) { + throw new Test262Error(); +} diff --git a/test/annexB/language/comments/single-line-html-close-asi.js b/test/annexB/language/comments/single-line-html-close-asi.js new file mode 100644 index 0000000000..d689436f1f --- /dev/null +++ b/test/annexB/language/comments/single-line-html-close-asi.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +es6id: B1.3 +description: > + A SingleLineHTMLCloseComment is considered to be a LineTerminator for + purposes of parsing by the syntactic grammar. +info: | + Comment :: + MultiLineComment + SingleLineComment + SingleLineHTMLOpenComment + SingleLineHTMLCloseComment + SingleLineDelimitedComment + + MultiLineComment :: + /* FirstCommentLine[opt] LineTerminator MultiLineCommentChars[opt] * / HTMLCloseComment[opt] + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: Test262Error +---*/ + +var foo = [23] +-->[0]; + +// 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. +if (foo[0] === 23) { + throw new Test262Error(); +} diff --git a/test/annexB/language/comments/single-line-html-close.js b/test/annexB/language/comments/single-line-html-close.js new file mode 100644 index 0000000000..3066811894 --- /dev/null +++ b/test/annexB/language/comments/single-line-html-close.js @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +es6id: B1.3 +description: SingleLineHTMLCloseComment +info: | + Comment :: + MultiLineComment + SingleLineComment + SingleLineHTMLOpenComment + SingleLineHTMLCloseComment + SingleLineDelimitedComment + + SingleLineHTMLCloseComment :: + LineTerminatorSequenceHTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: Test262Error +---*/ + +var counter = 0; +--> +counter += 1; + +-->the comment extends to these characters +counter += 1; + + -->the comment extends to these characters +counter += 1; + +/* optional SingleLineDelimitedCommentSequence */-->the comment extends to these characters +counter += 1; + +/**/ /* second optional SingleLineDelimitedCommentSequence */-->the comment extends to these characters +counter += 1; + +// 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. +if (counter === 5) { + throw new Test262Error(); +} diff --git a/test/annexB/language/comments/single-line-html-open.js b/test/annexB/language/comments/single-line-html-open.js new file mode 100644 index 0000000000..ae7188a702 --- /dev/null +++ b/test/annexB/language/comments/single-line-html-open.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +es6id: B1.3 +description: SingleLineHTMLOpenComment +info: | + Comment :: + MultiLineComment + SingleLineComment + SingleLineHTMLOpenComment + SingleLineHTMLCloseComment + SingleLineDelimitedComment + + SingleLineHTMLOpenComment :: + diff --git a/test/language/comments/single-line-html-close-without-lt.js b/test/language/comments/single-line-html-close-without-lt.js new file mode 100644 index 0000000000..770e24eec3 --- /dev/null +++ b/test/language/comments/single-line-html-close-without-lt.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +es6id: B1.3 +description: An HTMLCloseComment must be preceeded by a LineTerminator +info: | + Comment :: + MultiLineComment + SingleLineComment + SingleLineHTMLOpenComment + SingleLineHTMLCloseComment + SingleLineDelimitedComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: SyntaxError +---*/ + +;--> diff --git a/test/language/module-code/comment-multi-line-html-close.js b/test/language/module-code/comment-multi-line-html-close.js new file mode 100644 index 0000000000..22713d2a32 --- /dev/null +++ b/test/language/module-code/comment-multi-line-html-close.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + HTML-like comments are not available in module code + (MultiLineHTMLCloseComment) +esid: sec-html-like-comments +es6id: B1.3 +negative: SyntaxError +flags: [module] +---*/ + +/* +*/--> diff --git a/test/language/module-code/comment-single-line-html-close.js b/test/language/module-code/comment-single-line-html-close.js new file mode 100644 index 0000000000..6e86c6a148 --- /dev/null +++ b/test/language/module-code/comment-single-line-html-close.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + HTML-like comments are not available in module code + (SingleLineHTMLCloseComment) +esid: sec-html-like-comments +es6id: B1.3 +negative: SyntaxError +flags: [module] +---*/ + +--> diff --git a/test/language/module-code/comment-single-line-html-open.js b/test/language/module-code/comment-single-line-html-open.js new file mode 100644 index 0000000000..17f8af2724 --- /dev/null +++ b/test/language/module-code/comment-single-line-html-open.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + HTML-like comments are not available in module code + (SingleLineHTMLOpenComment) +esid: sec-html-like-comments +es6id: B1.3 +negative: SyntaxError +flags: [module] +---*/ + +