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

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

Issue 11358214: Remove 'type' and 'arguments' properties from Error object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 717c66519ff2e46c519ebdbd9a10ac9c87d51a61..d5f276d2228ad17543f03d79fbcba4f49092dbc6 100755
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1041,6 +1041,31 @@ TEST(ScopePositions) {
}
+i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
+ i::Handle<i::String> format = v8::Utils::OpenHandle(
+ *v8::String::New(data->BuildMessage()));
+ i::Vector<const char*> args = data->BuildArgs();
+ i::Handle<i::JSArray> args_array = FACTORY->NewJSArray(args.length());
+ for (int i = 0; i < args.length(); i++) {
+ i::JSArray::SetElement(args_array,
+ i,
+ v8::Utils::OpenHandle(*v8::String::New(args[i])),
+ NONE,
+ i::kNonStrictMode);
+ }
+ i::Handle<i::JSObject> builtins(i::Isolate::Current()->js_builtins_object());
+ i::Handle<i::Object> format_fun =
+ i::GetProperty(builtins, "FormatMessage");
+ i::Handle<i::Object> arg_handles[] = { format, args_array };
+ bool has_exception = false;
+ i::Handle<i::Object> result =
+ i::Execution::Call(format_fun, builtins, 2, arg_handles, &has_exception);
+ CHECK(!has_exception);
+ CHECK(result->IsString());
+ return i::Handle<i::String>::cast(result);
+}
+
+
void TestParserSync(i::Handle<i::String> source, int flags) {
uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit();
bool harmony_scoping = ((i::kLanguageModeMask & flags) == i::EXTENDED_MODE);
@@ -1067,18 +1092,15 @@ void TestParserSync(i::Handle<i::String> source, int flags) {
i::FunctionLiteral* function = parser.ParseProgram();
i::FLAG_harmony_scoping = save_harmony_scoping;
- i::String* type_string = NULL;
+ i::Handle<i::String> message_string;
Sven Panne 2012/11/14 08:40:35 Remove this line, merging it with the initializati
if (function == NULL) {
// Extract exception from the parser.
- i::Handle<i::String> type_symbol = FACTORY->LookupAsciiSymbol("type");
CHECK(i::Isolate::Current()->has_pending_exception());
i::MaybeObject* maybe_object = i::Isolate::Current()->pending_exception();
i::JSObject* exception = NULL;
CHECK(maybe_object->To(&exception));
-
- // Get the type string.
- maybe_object = exception->GetProperty(*type_symbol);
- CHECK(maybe_object->To(&type_string));
+ i::Handle<i::JSObject> exception_handle(exception);
+ message_string = i::GetProperty(exception_handle, "message");
}
// Check that preparsing fails iff parsing fails.
@@ -1089,7 +1111,7 @@ void TestParserSync(i::Handle<i::String> source, int flags) {
"with error:\n"
"\t%s\n"
"However, the parser succeeded",
- *source->ToCString(), data.BuildMessage());
+ *source->ToCString(), *FormatMessage(&data)->ToCString());
CHECK(false);
} else if (!data.has_error() && function == NULL) {
i::OS::Print(
@@ -1098,20 +1120,23 @@ void TestParserSync(i::Handle<i::String> source, int flags) {
"with error:\n"
"\t%s\n"
"However, the preparser succeeded",
- *source->ToCString(), *type_string->ToCString());
+ *source->ToCString(), *message_string->ToCString());
CHECK(false);
}
// Check that preparser and parser produce the same error.
if (function == NULL) {
- if (!type_string->IsEqualTo(i::CStrVector(data.BuildMessage()))) {
+ i::Handle<i::String> preparser_message = FormatMessage(&data);
+ if (!message_string->Equals(*preparser_message)) {
i::OS::Print(
"Expected parser and preparser to produce the same error on:\n"
"\t%s\n"
"However, found the following error messages\n"
"\tparser: %s\n"
"\tpreparser: %s\n",
- *source->ToCString(), *type_string->ToCString(), data.BuildMessage());
+ *source->ToCString(),
+ *message_string->ToCString(),
+ *preparser_message->ToCString());
CHECK(false);
}
}
« src/messages.js ('K') | « src/messages.js ('k') | test/mjsunit/array-reduce.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698