diff --git a/features.txt b/features.txt index cb85ff43d56832a43d662c44e487839dc95d8d44..df361ca51791dfbc28d4b3a3e8dc32cefcb8bb25 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 0000000000000000000000000000000000000000..bfee27d968d5fd29cc3f2b814cd0438059dbaafe --- /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 0d8f8d9fabc760417e12a629890d5906fafa7c16..6293923b5cda3ce6b10159d096c6011da3a08a23 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 0000000000000000000000000000000000000000..fef8fec7ece4ce67c23d877015c841cd9b3a756f --- /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 0000000000000000000000000000000000000000..4a64d3e55b26e9678636bc9535b6e17426eba47c --- /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 0000000000000000000000000000000000000000..f7a818a9c435155d71c5b9355bdb1a0a9759fcb6 --- /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 6d29abd2fc0f32a441f1c905527ec232cd91d8bd..b771ebf5dd22437a5b0c66ba62d1857a416d25f8 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 0000000000000000000000000000000000000000..d0ccaa10c17570fdee70bc8d8b15b63baed14b11 --- /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 0000000000000000000000000000000000000000..dbf8c90ec5a8f545569d77206da2601b19948032 --- /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 629bda6a7803b1521ece41a5794c5cb46f26ca44..f09210fe646f103b3b9676a47e097e1495d79325 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 8f69cd81bcbfb3999790aac2dc9641c20e0688b2..658afc21160fc5ed893369631af26a7e98913797 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 2bb5130902ac9be95e0af9971f4e482a74fc65dc..3c02a981e22305d7d0804fe3d878f1f1d756e693 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 fdc3f85bab7c2c04bd8b9d478833b7c9e9baae96..1da390faea5633a963381bc5bbb69471be7e3bb4 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 ea30c700f69fd590337369aee7a40ca4a532f23e..0cb52d718b18f397871c903e62283a71fd012023 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 27bc551e4f534b84fbcad0474cf17332ac9eaba9..a4001b67c687e8473b8da59b01c757029ce86951 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 824d903d9fe38aee7cac8aff8982eecc4440dfbb..79fbaaeea122a51f845bd86b793333cf40a5e4d4 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 b005a3f290c6a5c8cbe5643c59ba5842f9fabcef..beebac4a570e4434c1289ca01e0fbe39cad44be9 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 0000000000000000000000000000000000000000..29b624576fe9dd03eb0db011959b45837b910525 --- /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 edd975cfb7d689f0a1d24628f82c22ca252331b6..3195624adcfc6a46d6c15153348341c95f312a70 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 bff2aa6d8f09a8fdc658e58b8a349b3052a97e7f..188673fec0bdf465fc6c256fd82fe4790d0b7ef0 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 27d079ddf529ab046894172e861445b30bf03ebf..87915e80233f34de67efc38fe9219478e80f065c 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 365b5dc4ddd0d292bbd68599fc9b384a72a91976..6833e526256e33a4d1852172380542ba0a7cd24b 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 5145019f0442adc80f9fe68a915e085ba96c9e2d..5faa19b9d6c0200f44abe28d2793fd71fa7247c7 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 7be73bd36a5e892c1d1673f65154c050453c2dea..bde162419ef50fedb93c035f00b2faa842384db0 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 62ce7af3cc901556df0475e964ec8ba606a6b319..cf9272ce436cb44c5c3b96be2a4331a4a24725c5 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 d8a7a5e8b9c1a9adcdb798176aed60c3775cc37f..6ccbf98bd8fce99dd38a4f6c4884f0386c94aabe 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 ({}) {}