Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index c5c932b7516cc70738ad918a9311dabe1e985427..86dd0f99ddc4e1a5513048165c8aed02aeccac64 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -14257,6 +14257,8 @@ TEST(CatchStackOverflow) { |
"f();")); |
v8::Handle<v8::Value> result = script->Run(); |
CHECK(result.IsEmpty()); |
+ CHECK_EQ(v8::Exception::kStackOverflowError, |
+ v8::Exception::NativeErrorType(try_catch.Exception())); |
} |
@@ -22116,3 +22118,53 @@ TEST(TestFunctionCallOptimization) { |
ApiCallOptimizationChecker checker; |
checker.RunAll(); |
} |
+ |
+ |
+static void CheckExceptionType( |
+ const char* script, v8::Exception::ErrorType expected) { |
+ v8::TryCatch try_catch; |
+ CompileRun(script); |
+ if (!try_catch.HasCaught()) { |
+ CHECK_EQ(expected, v8::Exception::kNoError); |
+ } else { |
+ CHECK_EQ(expected, v8::Exception::NativeErrorType(try_catch.Exception())); |
+ } |
+} |
+ |
+ |
+THREADED_TEST(ExceptionTypes) { |
+ v8::Isolate* isolate = CcTest::isolate(); |
+ v8::HandleScope scope(isolate); |
+ LocalContext context; |
+ // Check throw errors. |
+ CheckExceptionType("1", v8::Exception::kNoError); |
+ CheckExceptionType("throw 1", v8::Exception::kNoError); |
+ CheckExceptionType("throw Error", v8::Exception::kNoError); |
+ CheckExceptionType("throw new Error()", v8::Exception::kError); |
+ CheckExceptionType("throw new TypeError()", v8::Exception::kTypeError); |
+ CheckExceptionType("throw new RangeError()", v8::Exception::kRangeError); |
+ CheckExceptionType("throw new SyntaxError()", v8::Exception::kSyntaxError); |
+ CheckExceptionType( |
+ "throw new ReferenceError()", v8::Exception::kReferenceError); |
+ CheckExceptionType("throw new URIError()", v8::Exception::kURIError); |
+ CheckExceptionType("throw new EvalError()", v8::Exception::kEvalError); |
+ // Check api constructed errors. |
+ CHECK_EQ(v8::Exception::kError, |
+ v8::Exception::NativeErrorType(v8::Exception::Error(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kTypeError, |
+ v8::Exception::NativeErrorType(v8::Exception::TypeError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kURIError, |
+ v8::Exception::NativeErrorType(v8::Exception::URIError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kEvalError, |
+ v8::Exception::NativeErrorType(v8::Exception::EvalError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kRangeError, |
+ v8::Exception::NativeErrorType(v8::Exception::RangeError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kSyntaxError, |
+ v8::Exception::NativeErrorType(v8::Exception::SyntaxError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kReferenceError, |
+ v8::Exception::NativeErrorType( |
+ v8::Exception::ReferenceError(v8_str("")))); |
+ CHECK_EQ(v8::Exception::kStackOverflowError, |
+ v8::Exception::NativeErrorType( |
+ v8::Exception::StackOverflowError(v8_str("")))); |
+} |