Debian Codegraph @

js/src/tests/test262/built-ins/Reflect/construct/newtarget-is-not-constructor-throws.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 26.1.2
5 description: >
6 Throws a TypeError if `newTarget` is not a constructor.
7 info: |
8 26.1.2 Reflect.construct ( target, argumentsList [, newTarget] )
9
10 ...
11 2. If newTarget is not present, let newTarget be target.
12 3. Else, if IsConstructor(newTarget) is false, throw a TypeError exception.
13 ...
14 features: [Reflect, Reflect.construct]
15 ---*/
16
17 assert.throws(TypeError, function() {
18 Reflect.construct(function() {}, [], 1);
19 });
20
21 assert.throws(TypeError, function() {
22 Reflect.construct(function() {}, [], null);
23 });
24
25 assert.throws(TypeError, function() {
26 Reflect.construct(function() {}, [], {});
27 });
28
29 assert.throws(TypeError, function() {
30 Reflect.construct(function() {}, [], Date.now);
31 });
32
33 reportCompare(0, 0);