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

28 lines
959 B
JavaScript
Raw Normal View History

// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
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
---*/
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`);
2018-12-03 22:55:42 +01:00
assert.throws(SyntaxError, () => ctor('#!\n_'), `${ctor.name} Call body`);
assert.throws(SyntaxError, () => new ctor('#!\n_', ''), `${ctor.name} Construct argument`);
2018-12-03 22:55:42 +01:00
assert.throws(SyntaxError, () => new ctor('#!\n_'), `${ctor.name} Construct body`);
}