Debian Codegraph @

js/src/jsapi-tests/testNewTargetInvokeConstructor.cpp

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "js/CallAndConstruct.h" // JS::Construct
6 #include "jsapi-tests/tests.h"
7
8 BEGIN_TEST(testNewTargetInvokeConstructor) {
9 JS::RootedValue func(cx);
10
11 EVAL(
12 "(function(expected) { if (expected !== new.target) throw new "
13 "Error('whoops'); })",
14 &func);
15
16 JS::RootedValueArray<1> args(cx);
17 args[0].set(func);
18
19 JS::RootedObject obj(cx);
20
21 CHECK(JS::Construct(cx, func, args, &obj));
22
23 return true;
24 }
25 END_TEST(testNewTargetInvokeConstructor)