test262/test/language/comments/hashbang/function-constructor.js

24 lines
829 B
JavaScript
Raw Normal View History

2018-12-03 22:55:42 +01:00
/*---
esid: pending
description: >
Hashbang comments should not be allowed in function evaluator contexts.
info: |
HashbangComment::
#! SingleLineCommentChars[opt]
2019-02-05 18:46:27 +01:00
features: [hashbang]
2018-12-03 22:55:42 +01:00
---*/
const AsyncFunction = (async function (){}).constructor;
const GeneratorFunction = (function *(){}).constructor;
const AsyncGeneratorFunction = (async function *(){}).constructor;
2019-02-05 18:46:27 +01:00
for (const ctor of [
2018-12-03 22:55:42 +01:00
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`);
}