Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index ab94085a95f0da53624a80c4b0edede4310bfb00..4a0e595b68922fc78acc183aa8dbd0a2076730ca 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -7264,6 +7264,49 @@ THREADED_TEST(CallAsFunction) { |
} |
+// Check whether a non-function object is callable. |
+THREADED_TEST(CallableObject) { |
+ v8::HandleScope scope; |
+ LocalContext context; |
+ |
+ { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
+ instance_template->SetCallAsFunctionHandler(call_as_function); |
+ Local<Object> instance = instance_template->NewInstance(); |
+ v8::TryCatch try_catch; |
+ |
+ CHECK(instance->IsCallable()); |
+ CHECK(!try_catch.HasCaught()); |
+ } |
+ |
+ { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); |
+ Local<Object> instance = instance_template->NewInstance(); |
+ v8::TryCatch try_catch; |
+ |
+ CHECK(!instance->IsCallable()); |
+ CHECK(!try_catch.HasCaught()); |
+ } |
+ |
+ { Local<FunctionTemplate> function_template = |
+ FunctionTemplate::New(call_as_function); |
+ Local<Function> function = function_template->GetFunction(); |
+ Local<Object> instance = function; |
+ v8::TryCatch try_catch; |
+ |
+ CHECK(instance->IsCallable()); |
+ CHECK(!try_catch.HasCaught()); |
+ } |
+ |
+ { Local<FunctionTemplate> function_template = FunctionTemplate::New(); |
+ Local<Function> function = function_template->GetFunction(); |
+ Local<Object> instance = function; |
+ v8::TryCatch try_catch; |
+ |
+ CHECK(instance->IsCallable()); |
+ CHECK(!try_catch.HasCaught()); |
+ } |
+} |
+ |
+ |
static int CountHandles() { |
return v8::HandleScope::NumberOfHandles(); |
} |