tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

instance-construct-throws.js (1009B)


      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 /*---
      5 esid: sec-generatorfunction
      6 description: The instance created by GeneratorFunction is not a constructor
      7 info: |
      8    25.2.1.1 GeneratorFunction ( p1, p2, … , pn, body )
      9 
     10    ...
     11    3. Return ? CreateDynamicFunction(C, NewTarget, "generator", args).
     12 
     13    19.2.1.1.1 Runtime Semantics: CreateDynamicFunction( constructor, newTarget, kind, args )
     14 
     15    ...
     16    34. If kind is "generator", then
     17        a. Let prototype be ObjectCreate(%GeneratorPrototype%).
     18        b. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: prototype,
     19            [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
     20    ...
     21 features: [generators]
     22 ---*/
     23 
     24 var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
     25 
     26 var instance = GeneratorFunction();
     27 
     28 assert.throws(TypeError, function() {
     29  new instance();
     30 })
     31 
     32 reportCompare(0, 0);