1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "jsapi-tests/tests.h"
10 BEGIN_TEST(testBoundFunction
) {
11 EXEC("function foo() {}");
12 JS::RootedValue
foo(cx
);
14 JS::RootedValue
bound(cx
);
15 EVAL("foo.bind(1)", &bound
);
17 JS::Rooted
<JSObject
*> foofun(cx
, &foo
.toObject());
18 JS::Rooted
<JSObject
*> boundfun(cx
, &bound
.toObject());
20 CHECK(!JS_ObjectIsBoundFunction(foofun
));
21 CHECK(JS_ObjectIsBoundFunction(boundfun
));
23 CHECK(!JS_GetBoundFunctionTarget(foofun
));
24 JSObject
* target
= JS_GetBoundFunctionTarget(boundfun
);
26 CHECK(JS_ObjectIsFunction(target
));
27 JS::RootedValue
targetVal(cx
, JS::ObjectValue(*target
));
28 CHECK_SAME(foo
, targetVal
);
32 END_TEST(testBoundFunction
)