Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: test/cctest/test-api.cc

Issue 176843003: Add StackOverflowError and expose error type to api. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix test Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.js ('k') | tools/v8heapconst.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(""))));
+}
« no previous file with comments | « src/runtime.js ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698