diff --git a/test/language/comments/hashbang-encoded-bang.js b/test/language/comments/hashbang-encoded-bang.js new file mode 100644 index 0000000000000000000000000000000000000000..0d8f8d9fabc760417e12a629890d5906fafa7c16 --- /dev/null +++ b/test/language/comments/hashbang-encoded-bang.js @@ -0,0 +1,10 @@ +#\u0021 +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ diff --git a/test/language/comments/hashbang-encoded-hash.js b/test/language/comments/hashbang-encoded-hash.js new file mode 100644 index 0000000000000000000000000000000000000000..6d29abd2fc0f32a441f1c905527ec232cd91d8bd --- /dev/null +++ b/test/language/comments/hashbang-encoded-hash.js @@ -0,0 +1,10 @@ +\u0023! +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ diff --git a/test/language/comments/hashbang-encoded-hashbang.js b/test/language/comments/hashbang-encoded-hashbang.js new file mode 100644 index 0000000000000000000000000000000000000000..629bda6a7803b1521ece41a5794c5cb46f26ca44 --- /dev/null +++ b/test/language/comments/hashbang-encoded-hashbang.js @@ -0,0 +1,10 @@ +\u0023\u0021 +/*--- +esid: pending +description: > + Hashbang comments should not be allowed to have encoded characters +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ diff --git a/test/language/comments/hashbang-eval.js b/test/language/comments/hashbang-eval.js new file mode 100644 index 0000000000000000000000000000000000000000..8f69cd81bcbfb3999790aac2dc9641c20e0688b2 --- /dev/null +++ b/test/language/comments/hashbang-eval.js @@ -0,0 +1,10 @@ +/*--- +esid: pending +description: > + Hashbang comments should be available in Script evaluator contexts. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +---*/ + +assert.sameValue(eval('#!\n'), undefined); diff --git a/test/language/comments/hashbang-function-body.js b/test/language/comments/hashbang-function-body.js new file mode 100644 index 0000000000000000000000000000000000000000..2bb5130902ac9be95e0af9971f4e482a74fc65dc --- /dev/null +++ b/test/language/comments/hashbang-function-body.js @@ -0,0 +1,14 @@ +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be allowed within function bodies. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ +function fn() {#! +} diff --git a/test/language/comments/hashbang-function-constructor.js b/test/language/comments/hashbang-function-constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..fdc3f85bab7c2c04bd8b9d478833b7c9e9baae96 --- /dev/null +++ b/test/language/comments/hashbang-function-constructor.js @@ -0,0 +1,22 @@ +/*--- +esid: pending +description: > + Hashbang comments should not be allowed in function evaluator contexts. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +---*/ +const AsyncFunction = (async function (){}).constructor; +const GeneratorFunction = (function *(){}).constructor; +const AsyncGeneratorFunction = (async function *(){}).constructor; +for (ctor of [ + Function, + AsyncFunction, + GeneratorFunction, + AsyncGeneratorFunction, +]) { + assert.throws(SyntaxError, () => ctor('#!\n_',''), `${ctor.name} Call argument`); + assert.throws(SyntaxError, () => ctor('#!\n_'), `${ctor.name} Call body`); + assert.throws(SyntaxError, () => new ctor('#!\n_',''), `${ctor.name} Construct argument`); + assert.throws(SyntaxError, () => new ctor('#!\n_'), `${ctor.name} Construct body`); +} diff --git a/test/language/comments/hashbang-module.js b/test/language/comments/hashbang-module.js new file mode 100644 index 0000000000000000000000000000000000000000..ea30c700f69fd590337369aee7a40ca4a532f23e --- /dev/null +++ b/test/language/comments/hashbang-module.js @@ -0,0 +1,10 @@ +#! +/*--- +esid: pending +description: > + Hashbang comments should be allowed in Modules. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [module] +---*/ diff --git a/test/language/comments/hashbang-multi-line-comment.js b/test/language/comments/hashbang-multi-line-comment.js new file mode 100644 index 0000000000000000000000000000000000000000..27bc551e4f534b84fbcad0474cf17332ac9eaba9 --- /dev/null +++ b/test/language/comments/hashbang-multi-line-comment.js @@ -0,0 +1,15 @@ +#!/* +these characters should not be considered within a comment +*/ +/*--- +esid: pending +description: > + Hashbang comments should not interpret multi-line comments. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..824d903d9fe38aee7cac8aff8982eecc4440dfbb --- /dev/null +++ b/test/language/comments/hashbang-no-line-separator.js @@ -0,0 +1,11 @@ +/*--- +esid: pending +description: > + Hashbang comments should not require a newline afterwards +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ + +eval('#!'); diff --git a/test/language/comments/hashbang-not-empty.js b/test/language/comments/hashbang-not-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..b005a3f290c6a5c8cbe5643c59ba5842f9fabcef --- /dev/null +++ b/test/language/comments/hashbang-not-empty.js @@ -0,0 +1,11 @@ +#! these characters should be treated as a comment +/*--- +esid: pending +description: > + Hashbang comments should be allowed in Scripts and should not be required to be empty. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ + diff --git a/test/language/comments/hashbang-preceding-directive-prologue.js b/test/language/comments/hashbang-preceding-directive-prologue.js new file mode 100644 index 0000000000000000000000000000000000000000..edd975cfb7d689f0a1d24628f82c22ca252331b6 --- /dev/null +++ b/test/language/comments/hashbang-preceding-directive-prologue.js @@ -0,0 +1,14 @@ +"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 +---*/ \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..bff2aa6d8f09a8fdc658e58b8a349b3052a97e7f --- /dev/null +++ b/test/language/comments/hashbang-preceding-empty-statement.js @@ -0,0 +1,13 @@ +;#! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be preceded by empty statements. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-hashbang.js b/test/language/comments/hashbang-preceding-hashbang.js new file mode 100644 index 0000000000000000000000000000000000000000..27d079ddf529ab046894172e861445b30bf03ebf --- /dev/null +++ b/test/language/comments/hashbang-preceding-hashbang.js @@ -0,0 +1,14 @@ +#! +#! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be preceded by Hashbang comments. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..365b5dc4ddd0d292bbd68599fc9b384a72a91976 --- /dev/null +++ b/test/language/comments/hashbang-preceding-line-comment.js @@ -0,0 +1,14 @@ +// +#! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be preceded by line comments. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..5145019f0442adc80f9fe68a915e085ba96c9e2d --- /dev/null +++ b/test/language/comments/hashbang-preceding-multi-line-comment.js @@ -0,0 +1,14 @@ +/* +*/#! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be preceded by multi-line comments. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-preceding-whitespace.js b/test/language/comments/hashbang-preceding-whitespace.js new file mode 100644 index 0000000000000000000000000000000000000000..7be73bd36a5e892c1d1673f65154c050453c2dea --- /dev/null +++ b/test/language/comments/hashbang-preceding-whitespace.js @@ -0,0 +1,13 @@ + #! +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be preceded by whitespace. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ \ No newline at end of file diff --git a/test/language/comments/hashbang-statement-block.js b/test/language/comments/hashbang-statement-block.js new file mode 100644 index 0000000000000000000000000000000000000000..62ce7af3cc901556df0475e964ec8ba606a6b319 --- /dev/null +++ b/test/language/comments/hashbang-statement-block.js @@ -0,0 +1,15 @@ +/*--- +esid: pending +description: > + Hashbang comments should only be allowed at the start of source texts and should not be allowed within blocks. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +negative: + phase: parse + type: SyntaxError +---*/ +{ + #! +} \ No newline at end of file diff --git a/test/language/comments/hashbang-use-strict.js b/test/language/comments/hashbang-use-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..d8a7a5e8b9c1a9adcdb798176aed60c3775cc37f --- /dev/null +++ b/test/language/comments/hashbang-use-strict.js @@ -0,0 +1,12 @@ +#!"use strict" +/*--- +esid: pending +description: > + Hashbang comments should not be interpretted and should not generate DirectivePrologues. +info: | + HashbangComment:: + #! SingleLineCommentChars[opt] +flags: [raw] +---*/ + +with ({}) {}