has-instance.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
  11. function* gDecl() {}
  12. var gExpr = function*() {};
  13. assert(
  14. gDecl instanceof GeneratorFunction,
  15. 'Generators created via GeneratorDeclaration syntax are proper instances of GeneratorFunction'
  16. );
  17. assert(
  18. gExpr instanceof GeneratorFunction,
  19. 'Generators created via GeneratorExpression syntax are proper instances of GeneratorFunction'
  20. );
  21. assert(
  22. new GeneratorFunction() instanceof GeneratorFunction,
  23. 'Generators created via constructor invocation of GeneratorFunction are proper instances of GeneratorFunction'
  24. );
  25. assert(
  26. GeneratorFunction() instanceof GeneratorFunction,
  27. 'Generators created via function invocation of GeneratorFunction are proper instances of GeneratorFunction'
  28. );