OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 if (function == NULL) { | 1242 if (function == NULL) { |
1243 // Extract exception from the parser. | 1243 // Extract exception from the parser. |
1244 CHECK(isolate->has_pending_exception()); | 1244 CHECK(isolate->has_pending_exception()); |
1245 i::Handle<i::JSObject> exception_handle( | 1245 i::Handle<i::JSObject> exception_handle( |
1246 i::JSObject::cast(isolate->pending_exception())); | 1246 i::JSObject::cast(isolate->pending_exception())); |
1247 i::Handle<i::String> message_string = | 1247 i::Handle<i::String> message_string = |
1248 i::Handle<i::String>::cast(i::Object::GetProperty( | 1248 i::Handle<i::String>::cast(i::Object::GetProperty( |
1249 isolate, exception_handle, "message").ToHandleChecked()); | 1249 isolate, exception_handle, "message").ToHandleChecked()); |
1250 | 1250 |
1251 if (result == kSuccess) { | 1251 if (result == kSuccess) { |
1252 i::OS::Print( | 1252 v8::base::OS::Print( |
1253 "Parser failed on:\n" | 1253 "Parser failed on:\n" |
1254 "\t%s\n" | 1254 "\t%s\n" |
1255 "with error:\n" | 1255 "with error:\n" |
1256 "\t%s\n" | 1256 "\t%s\n" |
1257 "However, we expected no error.", | 1257 "However, we expected no error.", |
1258 source->ToCString().get(), message_string->ToCString().get()); | 1258 source->ToCString().get(), message_string->ToCString().get()); |
1259 CHECK(false); | 1259 CHECK(false); |
1260 } | 1260 } |
1261 | 1261 |
1262 if (!data.has_error()) { | 1262 if (!data.has_error()) { |
1263 i::OS::Print( | 1263 v8::base::OS::Print( |
1264 "Parser failed on:\n" | 1264 "Parser failed on:\n" |
1265 "\t%s\n" | 1265 "\t%s\n" |
1266 "with error:\n" | 1266 "with error:\n" |
1267 "\t%s\n" | 1267 "\t%s\n" |
1268 "However, the preparser succeeded", | 1268 "However, the preparser succeeded", |
1269 source->ToCString().get(), message_string->ToCString().get()); | 1269 source->ToCString().get(), message_string->ToCString().get()); |
1270 CHECK(false); | 1270 CHECK(false); |
1271 } | 1271 } |
1272 // Check that preparser and parser produce the same error. | 1272 // Check that preparser and parser produce the same error. |
1273 i::Handle<i::String> preparser_message = FormatMessage(&data); | 1273 i::Handle<i::String> preparser_message = FormatMessage(&data); |
1274 if (!i::String::Equals(message_string, preparser_message)) { | 1274 if (!i::String::Equals(message_string, preparser_message)) { |
1275 i::OS::Print( | 1275 v8::base::OS::Print( |
1276 "Expected parser and preparser to produce the same error on:\n" | 1276 "Expected parser and preparser to produce the same error on:\n" |
1277 "\t%s\n" | 1277 "\t%s\n" |
1278 "However, found the following error messages\n" | 1278 "However, found the following error messages\n" |
1279 "\tparser: %s\n" | 1279 "\tparser: %s\n" |
1280 "\tpreparser: %s\n", | 1280 "\tpreparser: %s\n", |
1281 source->ToCString().get(), | 1281 source->ToCString().get(), |
1282 message_string->ToCString().get(), | 1282 message_string->ToCString().get(), |
1283 preparser_message->ToCString().get()); | 1283 preparser_message->ToCString().get()); |
1284 CHECK(false); | 1284 CHECK(false); |
1285 } | 1285 } |
1286 } else if (data.has_error()) { | 1286 } else if (data.has_error()) { |
1287 i::OS::Print( | 1287 v8::base::OS::Print( |
1288 "Preparser failed on:\n" | 1288 "Preparser failed on:\n" |
1289 "\t%s\n" | 1289 "\t%s\n" |
1290 "with error:\n" | 1290 "with error:\n" |
1291 "\t%s\n" | 1291 "\t%s\n" |
1292 "However, the parser succeeded", | 1292 "However, the parser succeeded", |
1293 source->ToCString().get(), FormatMessage(&data)->ToCString().get()); | 1293 source->ToCString().get(), FormatMessage(&data)->ToCString().get()); |
1294 CHECK(false); | 1294 CHECK(false); |
1295 } else if (result == kError) { | 1295 } else if (result == kError) { |
1296 i::OS::Print( | 1296 v8::base::OS::Print( |
1297 "Expected error on:\n" | 1297 "Expected error on:\n" |
1298 "\t%s\n" | 1298 "\t%s\n" |
1299 "However, parser and preparser succeeded", | 1299 "However, parser and preparser succeeded", |
1300 source->ToCString().get()); | 1300 source->ToCString().get()); |
1301 CHECK(false); | 1301 CHECK(false); |
1302 } | 1302 } |
1303 } | 1303 } |
1304 | 1304 |
1305 | 1305 |
1306 void TestParserSync(const char* source, | 1306 void TestParserSync(const char* source, |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); | 2034 factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); |
2035 i::Handle<i::Script> script = factory->NewScript(source); | 2035 i::Handle<i::Script> script = factory->NewScript(source); |
2036 i::CompilationInfoWithZone info(script); | 2036 i::CompilationInfoWithZone info(script); |
2037 i::ScriptData* data = NULL; | 2037 i::ScriptData* data = NULL; |
2038 info.SetCachedData(&data, i::PRODUCE_CACHED_DATA); | 2038 info.SetCachedData(&data, i::PRODUCE_CACHED_DATA); |
2039 i::Parser::Parse(&info, true); | 2039 i::Parser::Parse(&info, true); |
2040 CHECK(data); | 2040 CHECK(data); |
2041 CHECK(!data->HasError()); | 2041 CHECK(!data->HasError()); |
2042 | 2042 |
2043 if (data->function_count() != test_cases[i].functions) { | 2043 if (data->function_count() != test_cases[i].functions) { |
2044 i::OS::Print( | 2044 v8::base::OS::Print( |
2045 "Expected preparse data for program:\n" | 2045 "Expected preparse data for program:\n" |
2046 "\t%s\n" | 2046 "\t%s\n" |
2047 "to contain %d functions, however, received %d functions.\n", | 2047 "to contain %d functions, however, received %d functions.\n", |
2048 program, test_cases[i].functions, | 2048 program, test_cases[i].functions, |
2049 data->function_count()); | 2049 data->function_count()); |
2050 CHECK(false); | 2050 CHECK(false); |
2051 } | 2051 } |
2052 delete data; | 2052 delete data; |
2053 } | 2053 } |
2054 } | 2054 } |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 const i::AstRawString* var_name = | 2738 const i::AstRawString* var_name = |
2739 info.ast_value_factory()->GetOneByteString("x"); | 2739 info.ast_value_factory()->GetOneByteString("x"); |
2740 i::Variable* var = inner_scope->Lookup(var_name); | 2740 i::Variable* var = inner_scope->Lookup(var_name); |
2741 bool expected = outers[i].assigned || inners[j].assigned; | 2741 bool expected = outers[i].assigned || inners[j].assigned; |
2742 CHECK(var != NULL); | 2742 CHECK(var != NULL); |
2743 CHECK(var->is_used() || !expected); | 2743 CHECK(var->is_used() || !expected); |
2744 CHECK(var->maybe_assigned() == expected); | 2744 CHECK(var->maybe_assigned() == expected); |
2745 } | 2745 } |
2746 } | 2746 } |
2747 } | 2747 } |
OLD | NEW |