Commit 53f329ab authored by yangguo@chromium.org's avatar yangguo@chromium.org

Add test case for custom error's toString.

R=arv@chromium.org
BUG=
TEST=error-tostring.js

Review URL: https://chromiumcodereview.appspot.com/10388208

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12151 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 26afeb6e
......@@ -3057,6 +3057,32 @@ TEST(APIThrowMessageOverwrittenToString) {
}
static void check_custom_error_message(
v8::Handle<v8::Message> message,
v8::Handle<v8::Value> data) {
const char* uncaught_error = "Uncaught MyError toString";
CHECK(message->Get()->Equals(v8_str(uncaught_error)));
}
TEST(CustomErrorToString) {
v8::HandleScope scope;
v8::V8::AddMessageListener(check_custom_error_message);
LocalContext context;
CompileRun(
"function MyError(name, message) { "
" this.name = name; "
" this.message = message; "
"} "
"MyError.prototype = Object.create(Error.prototype); "
"MyError.prototype.toString = function() { "
" return 'MyError toString'; "
"}; "
"throw new MyError('my name', 'my message'); ");
v8::V8::RemoveMessageListeners(check_custom_error_message);
}
static void receive_message(v8::Handle<v8::Message> message,
v8::Handle<v8::Value> data) {
message->Get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment