Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 8d8770f13236637d6bfc727aa5a0facbe398611c..9769fb79ab5a04410343a424cbfc64095054c639 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -1026,6 +1026,90 @@ THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
} |
+THREADED_TEST(IsNativeError) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> syntax_error = CompileRun( |
+ "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); |
+ CHECK(syntax_error->IsNativeError()); |
+ v8::Handle<Value> not_error = CompileRun("{a:42}"); |
+ CHECK(!not_error->IsNativeError()); |
+ v8::Handle<Value> not_object = CompileRun("42"); |
+ CHECK(!not_object->IsNativeError()); |
+} |
+ |
+ |
+THREADED_TEST(StringObject) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); |
+ CHECK(boxed_string->IsStringObject()); |
+ v8::Handle<Value> unboxed_string = CompileRun("\"test\""); |
+ CHECK(!unboxed_string->IsStringObject()); |
+ v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); |
+ CHECK(!boxed_not_string->IsStringObject()); |
+ v8::Handle<Value> not_object = CompileRun("0"); |
+ CHECK(!not_object->IsStringObject()); |
+ v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>(); |
+ CHECK(!as_boxed.IsEmpty()); |
+ Local<v8::String> the_string = as_boxed->StringValue(); |
+ CHECK(!the_string.IsEmpty()); |
+ ExpectObject("\"test\"", the_string); |
+ v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string); |
+ CHECK(new_boxed_string->IsStringObject()); |
+ as_boxed = new_boxed_string.As<v8::StringObject>(); |
+ the_string = as_boxed->StringValue(); |
+ CHECK(!the_string.IsEmpty()); |
+ ExpectObject("\"test\"", the_string); |
+} |
+ |
+ |
+THREADED_TEST(NumberObject) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); |
+ CHECK(boxed_number->IsNumberObject()); |
+ v8::Handle<Value> unboxed_number = CompileRun("42"); |
+ CHECK(!unboxed_number->IsNumberObject()); |
+ v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); |
+ CHECK(!boxed_not_number->IsNumberObject()); |
+ v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); |
+ CHECK(!as_boxed.IsEmpty()); |
+ double the_number = as_boxed->NumberValue(); |
+ CHECK_EQ(42.0, the_number); |
+ v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); |
+ CHECK(new_boxed_number->IsNumberObject()); |
+ as_boxed = new_boxed_number.As<v8::NumberObject>(); |
+ the_number = as_boxed->NumberValue(); |
+ CHECK_EQ(43.0, the_number); |
+} |
+ |
+ |
+THREADED_TEST(BooleanObject) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); |
+ CHECK(boxed_boolean->IsBooleanObject()); |
+ v8::Handle<Value> unboxed_boolean = CompileRun("true"); |
+ CHECK(!unboxed_boolean->IsBooleanObject()); |
+ v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); |
+ CHECK(!boxed_not_boolean->IsBooleanObject()); |
+ v8::Handle<v8::BooleanObject> as_boxed = |
+ boxed_boolean.As<v8::BooleanObject>(); |
+ CHECK(!as_boxed.IsEmpty()); |
+ bool the_boolean = as_boxed->BooleanValue(); |
+ CHECK_EQ(true, the_boolean); |
+ v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true); |
+ v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false); |
+ CHECK(boxed_true->IsBooleanObject()); |
+ CHECK(boxed_false->IsBooleanObject()); |
+ as_boxed = boxed_true.As<v8::BooleanObject>(); |
+ CHECK_EQ(true, as_boxed->BooleanValue()); |
+ as_boxed = boxed_false.As<v8::BooleanObject>(); |
+ CHECK_EQ(false, as_boxed->BooleanValue()); |
+} |
+ |
+ |
THREADED_TEST(Number) { |
v8::HandleScope scope; |
LocalContext env; |