Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 8d8770f13236637d6bfc727aa5a0facbe398611c..05fc39f46804b06eeb03974ef179a273f711c0b2 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -1026,6 +1026,101 @@ 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(IsMath) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> maybe_math = CompileRun("Math"); |
+ CHECK(maybe_math->IsMath()); |
+ v8::Handle<Value> maybe_not = CompileRun("{a: 1}"); |
+ CHECK(!maybe_not->IsMath()); |
+ v8::Handle<Value> not_object = CompileRun("1"); |
+ CHECK(!not_object->IsMath()); |
+} |
+ |
+ |
+THREADED_TEST(BoxedString) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")"); |
+ CHECK(boxed_string->IsBoxedString()); |
+ v8::Handle<Value> unboxed_string = CompileRun("\"test\""); |
+ CHECK(!unboxed_string->IsBoxedString()); |
+ v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)"); |
+ CHECK(!boxed_not_string->IsBoxedString()); |
+ v8::Handle<Value> not_object = CompileRun("0"); |
+ CHECK(!not_object->IsBoxedString()); |
+ v8::Handle<v8::BoxedString> as_boxed = boxed_string.As<v8::BoxedString>(); |
+ 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::BoxedString::New(the_string); |
+ CHECK(new_boxed_string->IsBoxedString()); |
+ as_boxed = new_boxed_string.As<v8::BoxedString>(); |
+ the_string = as_boxed->StringValue(); |
+ CHECK(!the_string.IsEmpty()); |
+ ExpectObject("\"test\"", the_string); |
+} |
+ |
+ |
+THREADED_TEST(BoxedNumber) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); |
+ CHECK(boxed_number->IsBoxedNumber()); |
+ v8::Handle<Value> unboxed_number = CompileRun("42"); |
+ CHECK(!unboxed_number->IsBoxedNumber()); |
+ v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); |
+ CHECK(!boxed_not_number->IsBoxedNumber()); |
+ v8::Handle<v8::BoxedNumber> as_boxed = boxed_number.As<v8::BoxedNumber>(); |
+ CHECK(!as_boxed.IsEmpty()); |
+ double the_number = as_boxed->NumberValue(); |
+ CHECK_EQ(42.0, the_number); |
+ v8::Handle<v8::Value> new_boxed_number = v8::BoxedNumber::New(43); |
+ CHECK(new_boxed_number->IsBoxedNumber()); |
+ as_boxed = new_boxed_number.As<v8::BoxedNumber>(); |
+ the_number = as_boxed->NumberValue(); |
+ CHECK_EQ(43.0, the_number); |
+} |
+ |
+ |
+THREADED_TEST(BoxedBoolean) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)"); |
+ CHECK(boxed_boolean->IsBoxedBoolean()); |
+ v8::Handle<Value> unboxed_boolean = CompileRun("true"); |
+ CHECK(!unboxed_boolean->IsBoxedBoolean()); |
+ v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)"); |
+ CHECK(!boxed_not_boolean->IsBoxedBoolean()); |
+ v8::Handle<v8::BoxedBoolean> as_boxed = boxed_boolean.As<v8::BoxedBoolean>(); |
+ CHECK(!as_boxed.IsEmpty()); |
+ bool the_boolean = as_boxed->BooleanValue(); |
+ CHECK_EQ(true, the_boolean); |
+ v8::Handle<v8::Value> boxed_true = v8::BoxedBoolean::New(true); |
+ v8::Handle<v8::Value> boxed_false = v8::BoxedBoolean::New(false); |
+ CHECK(boxed_true->IsBoxedBoolean()); |
+ CHECK(boxed_false->IsBoxedBoolean()); |
+ as_boxed = boxed_true.As<v8::BoxedBoolean>(); |
+ CHECK_EQ(true, as_boxed->BooleanValue()); |
+ as_boxed = boxed_false.As<v8::BoxedBoolean>(); |
+ CHECK_EQ(false, as_boxed->BooleanValue()); |
+} |
+ |
+ |
THREADED_TEST(Number) { |
v8::HandleScope scope; |
LocalContext env; |