function-constructor.js (981B)
1 // Copyright (C) 2019 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: pending 6 description: > 7 Hashbang comments should not be allowed in function evaluator contexts. 8 info: | 9 HashbangComment:: 10 #! SingleLineCommentChars[opt] 11 features: [hashbang] 12 ---*/ 13 14 const AsyncFunction = (async function (){}).constructor; 15 const GeneratorFunction = (function *(){}).constructor; 16 const AsyncGeneratorFunction = (async function *(){}).constructor; 17 for (const ctor of [ 18 Function, 19 AsyncFunction, 20 GeneratorFunction, 21 AsyncGeneratorFunction, 22 ]) { 23 assert.throws(SyntaxError, () => ctor('#!\n_', ''), `${ctor.name} Call argument`); 24 assert.throws(SyntaxError, () => ctor('#!\n_'), `${ctor.name} Call body`); 25 assert.throws(SyntaxError, () => new ctor('#!\n_', ''), `${ctor.name} Construct argument`); 26 assert.throws(SyntaxError, () => new ctor('#!\n_'), `${ctor.name} Construct body`); 27 } 28 29 reportCompare(0, 0);