has-instance.js (1105B)
1 // Copyright (C) 2013 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 25.2 5 description: > 6 Generator function instances are correctly reported as instances of the 7 GeneratorFunction intrinsic. 8 features: [generators] 9 ---*/ 10 11 var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor; 12 13 function* gDecl() {} 14 var gExpr = function*() {}; 15 16 assert( 17 gDecl instanceof GeneratorFunction, 18 'Generators created via GeneratorDeclaration syntax are proper instances of GeneratorFunction' 19 ); 20 21 assert( 22 gExpr instanceof GeneratorFunction, 23 'Generators created via GeneratorExpression syntax are proper instances of GeneratorFunction' 24 ); 25 26 assert( 27 new GeneratorFunction() instanceof GeneratorFunction, 28 'Generators created via constructor invocation of GeneratorFunction are proper instances of GeneratorFunction' 29 ); 30 31 assert( 32 GeneratorFunction() instanceof GeneratorFunction, 33 'Generators created via function invocation of GeneratorFunction are proper instances of GeneratorFunction' 34 ); 35 36 reportCompare(0, 0);