summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/GeneratorFunction/instance-construct-throws.js
blob: db16b01eb1dd5b820ebe0956ec4cd388b5dbae51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-generatorfunction
description: The instance created by GeneratorFunction is not a constructor
info: |
    25.2.1.1 GeneratorFunction ( p1, p2, … , pn, body )

    ...
    3. Return ? CreateDynamicFunction(C, NewTarget, "generator", args).

    19.2.1.1.1 Runtime Semantics: CreateDynamicFunction( constructor, newTarget, kind, args )

    ...
    34. If kind is "generator", then
        a. Let prototype be ObjectCreate(%GeneratorPrototype%).
        b. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: prototype,
            [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
    ...
features: [generators]
---*/

var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;

var instance = GeneratorFunction();

assert.throws(TypeError, function() {
  new instance();
})

reportCompare(0, 0);