instance-construct-throws.js 987 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2017 the V8 project authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-generatorfunction
  5. description: The instance created by GeneratorFunction is not a constructor
  6. info: |
  7. 25.2.1.1 GeneratorFunction ( p1, p2, … , pn, body )
  8. ...
  9. 3. Return ? CreateDynamicFunction(C, NewTarget, "generator", args).
  10. 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction( constructor, newTarget, kind, args )
  11. ...
  12. 34. If kind is "generator", then
  13. a. Let prototype be ObjectCreate(%GeneratorPrototype%).
  14. b. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: prototype,
  15. [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
  16. ...
  17. features: [generators]
  18. ---*/
  19. var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
  20. var instance = GeneratorFunction();
  21. assert.throws(TypeError, function() {
  22. new instance();
  23. })