From 353cf531d623423cfebda1e1abd112131d704f9d Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Tue, 5 Feb 2019 12:46:27 -0500 Subject: [PATCH] Apply review feedback for hashbang --- features.txt | 4 ++++ .../comments/hashbang/encoded-bang-041.js | 14 ++++++++++++++ .../encoded-bang-u0021.js} | 6 +++++- .../comments/hashbang/encoded-bang-u21.js | 14 ++++++++++++++ .../comments/hashbang/encoded-bang-x21.js | 14 ++++++++++++++ .../comments/hashbang/encoded-hash-043.js | 14 ++++++++++++++ .../encoded-hash-u0023.js} | 6 +++++- .../comments/hashbang/encoded-hash-u23.js | 14 ++++++++++++++ .../comments/hashbang/encoded-hash-x23.js | 14 ++++++++++++++ .../encoded-hashbang.js} | 4 ++++ .../{hashbang-eval.js => hashbang/eval.js} | 3 +++ .../function-body.js} | 4 ++++ .../function-constructor.js} | 3 ++- .../{hashbang-module.js => hashbang/module.js} | 1 + .../multi-line-comment.js} | 2 ++ .../no-line-separator.js} | 3 ++- .../not-empty.js} | 1 + .../hashbang/preceding-directive-prologue-sc.js | 15 +++++++++++++++ .../preceding-directive-prologue.js} | 1 + .../preceding-empty-statement.js} | 1 + .../preceding-hashbang.js} | 1 + .../preceding-line-comment.js} | 1 + .../preceding-multi-line-comment.js} | 1 + .../preceding-whitespace.js} | 3 ++- .../statement-block.js} | 1 + .../use-strict.js} | 3 ++- 26 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 test/language/comments/hashbang/encoded-bang-041.js rename test/language/comments/{hashbang-encoded-bang.js => hashbang/encoded-bang-u0021.js} (70%) create mode 100644 test/language/comments/hashbang/encoded-bang-u21.js create mode 100644 test/language/comments/hashbang/encoded-bang-x21.js create mode 100644 test/language/comments/hashbang/encoded-hash-043.js rename test/language/comments/{hashbang-encoded-hash.js => hashbang/encoded-hash-u0023.js} (70%) create mode 100644 test/language/comments/hashbang/encoded-hash-u23.js create mode 100644 test/language/comments/hashbang/encoded-hash-x23.js rename test/language/comments/{hashbang-encoded-hashbang.js => hashbang/encoded-hashbang.js} (75%) rename test/language/comments/{hashbang-eval.js => hashbang/eval.js} (69%) rename test/language/comments/{hashbang-function-body.js => hashbang/function-body.js} (88%) rename test/language/comments/{hashbang-function-constructor.js => hashbang/function-constructor.js} (94%) rename test/language/comments/{hashbang-module.js => hashbang/module.js} (89%) rename test/language/comments/{hashbang-multi-line-comment.js => hashbang/multi-line-comment.js} (88%) rename test/language/comments/{hashbang-no-line-separator.js => hashbang/no-line-separator.js} (74%) rename test/language/comments/{hashbang-not-empty.js => hashbang/not-empty.js} (92%) create mode 100644 test/language/comments/hashbang/preceding-directive-prologue-sc.js rename test/language/comments/{hashbang-preceding-directive-prologue.js => hashbang/preceding-directive-prologue.js} (93%) rename test/language/comments/{hashbang-preceding-empty-statement.js => hashbang/preceding-empty-statement.js} (93%) rename test/language/comments/{hashbang-preceding-hashbang.js => hashbang/preceding-hashbang.js} (93%) rename test/language/comments/{hashbang-preceding-line-comment.js => hashbang/preceding-line-comment.js} (93%) rename test/language/comments/{hashbang-preceding-multi-line-comment.js => hashbang/preceding-multi-line-comment.js} (93%) rename test/language/comments/{hashbang-preceding-whitespace.js => hashbang/preceding-whitespace.js} (91%) rename test/language/comments/{hashbang-statement-block.js => hashbang/statement-block.js} (93%) rename test/language/comments/{hashbang-use-strict.js => hashbang/use-strict.js} (57%) diff --git a/features.txt b/features.txt index cb85ff43d5..df361ca517 100644 --- a/features.txt +++ b/features.txt @@ -7,6 +7,10 @@ # # https://github.com/tc39/process-document +# Hashbang Grammar +# https://github.com/tc39/proposal-hashbang +hashbang + # Object.fromEntries # https://github.com/tc39/proposal-object-from-entries Object.fromEntries diff --git a/test/language/comments/hashbang/encoded-bang-041.js b/test/language/comments/hashbang/encoded-bang-041.js new file mode 100644 index 0000000000..bfee27d968 --- /dev/null +++ b/test/language/comments/hashbang/encoded-bang-041.js @@ -0,0 +1,14 @@ +#\041 +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \041 +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang-encoded-bang.js b/test/language/comments/hashbang/encoded-bang-u0021.js similarity index 70% rename from test/language/comments/hashbang-encoded-bang.js rename to test/language/comments/hashbang/encoded-bang-u0021.js index 0d8f8d9fab..6293923b5c 100644 --- a/test/language/comments/hashbang-encoded-bang.js +++ b/test/language/comments/hashbang/encoded-bang-u0021.js @@ -2,9 +2,13 @@ /*--- esid: pending description: > - Hashbang comments should not be allowed to have encoded characters + Hashbang comments should not be allowed to have encoded characters \u0021 info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] ---*/ diff --git a/test/language/comments/hashbang/encoded-bang-u21.js b/test/language/comments/hashbang/encoded-bang-u21.js new file mode 100644 index 0000000000..fef8fec7ec --- /dev/null +++ b/test/language/comments/hashbang/encoded-bang-u21.js @@ -0,0 +1,14 @@ +#\u{21} +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \u{21} +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang/encoded-bang-x21.js b/test/language/comments/hashbang/encoded-bang-x21.js new file mode 100644 index 0000000000..4a64d3e55b --- /dev/null +++ b/test/language/comments/hashbang/encoded-bang-x21.js @@ -0,0 +1,14 @@ +#\x21 +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \x21 +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang/encoded-hash-043.js b/test/language/comments/hashbang/encoded-hash-043.js new file mode 100644 index 0000000000..f7a818a9c4 --- /dev/null +++ b/test/language/comments/hashbang/encoded-hash-043.js @@ -0,0 +1,14 @@ +\043! +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \043 +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang-encoded-hash.js b/test/language/comments/hashbang/encoded-hash-u0023.js similarity index 70% rename from test/language/comments/hashbang-encoded-hash.js rename to test/language/comments/hashbang/encoded-hash-u0023.js index 6d29abd2fc..b771ebf5dd 100644 --- a/test/language/comments/hashbang-encoded-hash.js +++ b/test/language/comments/hashbang/encoded-hash-u0023.js @@ -2,9 +2,13 @@ /*--- esid: pending description: > - Hashbang comments should not be allowed to have encoded characters + Hashbang comments should not be allowed to have encoded characters \u0023 info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] ---*/ diff --git a/test/language/comments/hashbang/encoded-hash-u23.js b/test/language/comments/hashbang/encoded-hash-u23.js new file mode 100644 index 0000000000..d0ccaa10c1 --- /dev/null +++ b/test/language/comments/hashbang/encoded-hash-u23.js @@ -0,0 +1,14 @@ +\u{23}! +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \u{23} +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang/encoded-hash-x23.js b/test/language/comments/hashbang/encoded-hash-x23.js new file mode 100644 index 0000000000..dbf8c90ec5 --- /dev/null +++ b/test/language/comments/hashbang/encoded-hash-x23.js @@ -0,0 +1,14 @@ +\x23! +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters \x23 +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ diff --git a/test/language/comments/hashbang-encoded-hashbang.js b/test/language/comments/hashbang/encoded-hashbang.js similarity index 75% rename from test/language/comments/hashbang-encoded-hashbang.js rename to test/language/comments/hashbang/encoded-hashbang.js index 629bda6a78..f09210fe64 100644 --- a/test/language/comments/hashbang-encoded-hashbang.js +++ b/test/language/comments/hashbang/encoded-hashbang.js @@ -7,4 +7,8 @@ info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] ---*/ diff --git a/test/language/comments/hashbang-eval.js b/test/language/comments/hashbang/eval.js similarity index 69% rename from test/language/comments/hashbang-eval.js rename to test/language/comments/hashbang/eval.js index 8f69cd81bc..658afc2116 100644 --- a/test/language/comments/hashbang-eval.js +++ b/test/language/comments/hashbang/eval.js @@ -5,6 +5,9 @@ description: > info: | HashbangComment:: #! SingleLineCommentChars[opt] +features: [hashbang] ---*/ assert.sameValue(eval('#!\n'), undefined); +assert.sameValue(eval('#!\n1'), 1) +assert.sameValue(eval('#!2\n'), undefined); diff --git a/test/language/comments/hashbang-function-body.js b/test/language/comments/hashbang/function-body.js similarity index 88% rename from test/language/comments/hashbang-function-body.js rename to test/language/comments/hashbang/function-body.js index 2bb5130902..3c02a981e2 100644 --- a/test/language/comments/hashbang-function-body.js +++ b/test/language/comments/hashbang/function-body.js @@ -9,6 +9,10 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ + +DONOTEVALUATE(); + function fn() {#! } diff --git a/test/language/comments/hashbang-function-constructor.js b/test/language/comments/hashbang/function-constructor.js similarity index 94% rename from test/language/comments/hashbang-function-constructor.js rename to test/language/comments/hashbang/function-constructor.js index fdc3f85bab..1da390faea 100644 --- a/test/language/comments/hashbang-function-constructor.js +++ b/test/language/comments/hashbang/function-constructor.js @@ -5,11 +5,12 @@ description: > info: | HashbangComment:: #! SingleLineCommentChars[opt] +features: [hashbang] ---*/ const AsyncFunction = (async function (){}).constructor; const GeneratorFunction = (function *(){}).constructor; const AsyncGeneratorFunction = (async function *(){}).constructor; -for (ctor of [ +for (const ctor of [ Function, AsyncFunction, GeneratorFunction, diff --git a/test/language/comments/hashbang-module.js b/test/language/comments/hashbang/module.js similarity index 89% rename from test/language/comments/hashbang-module.js rename to test/language/comments/hashbang/module.js index ea30c700f6..0cb52d718b 100644 --- a/test/language/comments/hashbang-module.js +++ b/test/language/comments/hashbang/module.js @@ -7,4 +7,5 @@ info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [module] +features: [hashbang] ---*/ diff --git a/test/language/comments/hashbang-multi-line-comment.js b/test/language/comments/hashbang/multi-line-comment.js similarity index 88% rename from test/language/comments/hashbang-multi-line-comment.js rename to test/language/comments/hashbang/multi-line-comment.js index 27bc551e4f..a4001b67c6 100644 --- a/test/language/comments/hashbang-multi-line-comment.js +++ b/test/language/comments/hashbang/multi-line-comment.js @@ -1,4 +1,5 @@ #!/* +DONOTEVALUATE(); these characters should not be considered within a comment */ /*--- @@ -12,4 +13,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-no-line-separator.js b/test/language/comments/hashbang/no-line-separator.js similarity index 74% rename from test/language/comments/hashbang-no-line-separator.js rename to test/language/comments/hashbang/no-line-separator.js index 824d903d9f..79fbaaeea1 100644 --- a/test/language/comments/hashbang-no-line-separator.js +++ b/test/language/comments/hashbang/no-line-separator.js @@ -6,6 +6,7 @@ info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +features: [hashbang] ---*/ -eval('#!'); +assert.sameValue(eval('#!'), undefined); diff --git a/test/language/comments/hashbang-not-empty.js b/test/language/comments/hashbang/not-empty.js similarity index 92% rename from test/language/comments/hashbang-not-empty.js rename to test/language/comments/hashbang/not-empty.js index b005a3f290..beebac4a57 100644 --- a/test/language/comments/hashbang-not-empty.js +++ b/test/language/comments/hashbang/not-empty.js @@ -7,5 +7,6 @@ info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +features: [hashbang] ---*/ diff --git a/test/language/comments/hashbang/preceding-directive-prologue-sc.js b/test/language/comments/hashbang/preceding-directive-prologue-sc.js new file mode 100644 index 0000000000..29b624576f --- /dev/null +++ b/test/language/comments/hashbang/preceding-directive-prologue-sc.js @@ -0,0 +1,15 @@ +"use strict"; +#! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at start of source texts and should not be preceded by DirectivePrologues. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +features: [hashbang] +---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-directive-prologue.js b/test/language/comments/hashbang/preceding-directive-prologue.js similarity index 93% rename from test/language/comments/hashbang-preceding-directive-prologue.js rename to test/language/comments/hashbang/preceding-directive-prologue.js index edd975cfb7..3195624adc 100644 --- a/test/language/comments/hashbang-preceding-directive-prologue.js +++ b/test/language/comments/hashbang/preceding-directive-prologue.js @@ -11,4 +11,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-empty-statement.js b/test/language/comments/hashbang/preceding-empty-statement.js similarity index 93% rename from test/language/comments/hashbang-preceding-empty-statement.js rename to test/language/comments/hashbang/preceding-empty-statement.js index bff2aa6d8f..188673fec0 100644 --- a/test/language/comments/hashbang-preceding-empty-statement.js +++ b/test/language/comments/hashbang/preceding-empty-statement.js @@ -10,4 +10,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-hashbang.js b/test/language/comments/hashbang/preceding-hashbang.js similarity index 93% rename from test/language/comments/hashbang-preceding-hashbang.js rename to test/language/comments/hashbang/preceding-hashbang.js index 27d079ddf5..87915e8023 100644 --- a/test/language/comments/hashbang-preceding-hashbang.js +++ b/test/language/comments/hashbang/preceding-hashbang.js @@ -11,4 +11,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-line-comment.js b/test/language/comments/hashbang/preceding-line-comment.js similarity index 93% rename from test/language/comments/hashbang-preceding-line-comment.js rename to test/language/comments/hashbang/preceding-line-comment.js index 365b5dc4dd..6833e52625 100644 --- a/test/language/comments/hashbang-preceding-line-comment.js +++ b/test/language/comments/hashbang/preceding-line-comment.js @@ -11,4 +11,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-multi-line-comment.js b/test/language/comments/hashbang/preceding-multi-line-comment.js similarity index 93% rename from test/language/comments/hashbang-preceding-multi-line-comment.js rename to test/language/comments/hashbang/preceding-multi-line-comment.js index 5145019f04..5faa19b9d6 100644 --- a/test/language/comments/hashbang-preceding-multi-line-comment.js +++ b/test/language/comments/hashbang/preceding-multi-line-comment.js @@ -11,4 +11,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-whitespace.js b/test/language/comments/hashbang/preceding-whitespace.js similarity index 91% rename from test/language/comments/hashbang-preceding-whitespace.js rename to test/language/comments/hashbang/preceding-whitespace.js index 7be73bd36a..bde162419e 100644 --- a/test/language/comments/hashbang-preceding-whitespace.js +++ b/test/language/comments/hashbang/preceding-whitespace.js @@ -1,4 +1,4 @@ - #! + #! /*--- esid: pending description: > @@ -10,4 +10,5 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-statement-block.js b/test/language/comments/hashbang/statement-block.js similarity index 93% rename from test/language/comments/hashbang-statement-block.js rename to test/language/comments/hashbang/statement-block.js index 62ce7af3cc..cf9272ce43 100644 --- a/test/language/comments/hashbang-statement-block.js +++ b/test/language/comments/hashbang/statement-block.js @@ -9,6 +9,7 @@ flags: [raw] negative: phase: parse type: SyntaxError +features: [hashbang] ---*/ { #! diff --git a/test/language/comments/hashbang-use-strict.js b/test/language/comments/hashbang/use-strict.js similarity index 57% rename from test/language/comments/hashbang-use-strict.js rename to test/language/comments/hashbang/use-strict.js index d8a7a5e8b9..6ccbf98bd8 100644 --- a/test/language/comments/hashbang-use-strict.js +++ b/test/language/comments/hashbang/use-strict.js @@ -2,11 +2,12 @@ /*--- esid: pending description: > - Hashbang comments should not be interpretted and should not generate DirectivePrologues. + Hashbang comments should not be interpreted and should not generate DirectivePrologues. info: | HashbangComment:: #! SingleLineCommentChars[opt] flags: [raw] +features: [hashbang] ---*/ with ({}) {} -- GitLab