mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Add tests for Hashbang comments
This commit is contained in:
parent
33a306d102
commit
da8ef2e779
10
test/language/comments/hashbang-encoded-bang.js
Normal file
10
test/language/comments/hashbang-encoded-bang.js
Normal file
@ -0,0 +1,10 @@
|
||||
#\u0021
|
||||
/*---
|
||||
esid: pending
|
||||
description: >
|
||||
Hashbang comments should not be allowed to have encoded characters
|
||||
info: |
|
||||
HashbangComment::
|
||||
#! SingleLineCommentChars[opt]
|
||||
flags: [raw]
|
||||
---*/
|
10
test/language/comments/hashbang-encoded-hash.js
Normal file
10
test/language/comments/hashbang-encoded-hash.js
Normal file
@ -0,0 +1,10 @@
|
||||
\u0023!
|
||||
/*---
|
||||
esid: pending
|
||||
description: >
|
||||
Hashbang comments should not be allowed to have encoded characters
|
||||
info: |
|
||||
HashbangComment::
|
||||
#! SingleLineCommentChars[opt]
|
||||
flags: [raw]
|
||||
---*/
|
10
test/language/comments/hashbang-encoded-hashbang.js
Normal file
10
test/language/comments/hashbang-encoded-hashbang.js
Normal file
@ -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]
|
||||
---*/
|
10
test/language/comments/hashbang-eval.js
Normal file
10
test/language/comments/hashbang-eval.js
Normal file
@ -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);
|
14
test/language/comments/hashbang-function-body.js
Normal file
14
test/language/comments/hashbang-function-body.js
Normal file
@ -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() {#!
|
||||
}
|
22
test/language/comments/hashbang-function-constructor.js
Normal file
22
test/language/comments/hashbang-function-constructor.js
Normal file
@ -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`);
|
||||
}
|
10
test/language/comments/hashbang-module.js
Normal file
10
test/language/comments/hashbang-module.js
Normal file
@ -0,0 +1,10 @@
|
||||
#!
|
||||
/*---
|
||||
esid: pending
|
||||
description: >
|
||||
Hashbang comments should be allowed in Modules.
|
||||
info: |
|
||||
HashbangComment::
|
||||
#! SingleLineCommentChars[opt]
|
||||
flags: [module]
|
||||
---*/
|
15
test/language/comments/hashbang-multi-line-comment.js
Normal file
15
test/language/comments/hashbang-multi-line-comment.js
Normal file
@ -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
|
||||
---*/
|
11
test/language/comments/hashbang-no-line-separator.js
Normal file
11
test/language/comments/hashbang-no-line-separator.js
Normal file
@ -0,0 +1,11 @@
|
||||
/*---
|
||||
esid: pending
|
||||
description: >
|
||||
Hashbang comments should not require a newline afterwards
|
||||
info: |
|
||||
HashbangComment::
|
||||
#! SingleLineCommentChars[opt]
|
||||
flags: [raw]
|
||||
---*/
|
||||
|
||||
eval('#!');
|
11
test/language/comments/hashbang-not-empty.js
Normal file
11
test/language/comments/hashbang-not-empty.js
Normal file
@ -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]
|
||||
---*/
|
||||
|
@ -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
|
||||
---*/
|
13
test/language/comments/hashbang-preceding-empty-statement.js
Normal file
13
test/language/comments/hashbang-preceding-empty-statement.js
Normal file
@ -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
|
||||
---*/
|
14
test/language/comments/hashbang-preceding-hashbang.js
Normal file
14
test/language/comments/hashbang-preceding-hashbang.js
Normal file
@ -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
|
||||
---*/
|
14
test/language/comments/hashbang-preceding-line-comment.js
Normal file
14
test/language/comments/hashbang-preceding-line-comment.js
Normal file
@ -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
|
||||
---*/
|
@ -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
|
||||
---*/
|
13
test/language/comments/hashbang-preceding-whitespace.js
Normal file
13
test/language/comments/hashbang-preceding-whitespace.js
Normal file
@ -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
|
||||
---*/
|
15
test/language/comments/hashbang-statement-block.js
Normal file
15
test/language/comments/hashbang-statement-block.js
Normal file
@ -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
|
||||
---*/
|
||||
{
|
||||
#!
|
||||
}
|
12
test/language/comments/hashbang-use-strict.js
Normal file
12
test/language/comments/hashbang-use-strict.js
Normal file
@ -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 ({}) {}
|
Loading…
x
Reference in New Issue
Block a user