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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/cctest/test-platform.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 i::Token::Value expected = expected_tokens[i]; 626 i::Token::Value expected = expected_tokens[i];
627 i::Token::Value actual = scanner.Next(); 627 i::Token::Value actual = scanner.Next();
628 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); 628 CHECK_EQ(i::Token::String(expected), i::Token::String(actual));
629 if (scanner.location().end_pos == skip_pos) { 629 if (scanner.location().end_pos == skip_pos) {
630 scanner.SeekForward(skip_to); 630 scanner.SeekForward(skip_to);
631 } 631 }
632 i++; 632 i++;
633 } while (expected_tokens[i] != i::Token::ILLEGAL); 633 } while (expected_tokens[i] != i::Token::ILLEGAL);
634 } 634 }
635 635
636
636 TEST(StreamScanner) { 637 TEST(StreamScanner) {
637 v8::V8::Initialize(); 638 v8::V8::Initialize();
638 639
639 const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib"; 640 const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib";
640 i::Utf8ToUtf16CharacterStream stream1(reinterpret_cast<const i::byte*>(str1), 641 i::Utf8ToUtf16CharacterStream stream1(reinterpret_cast<const i::byte*>(str1),
641 static_cast<unsigned>(strlen(str1))); 642 static_cast<unsigned>(strlen(str1)));
642 i::Token::Value expectations1[] = { 643 i::Token::Value expectations1[] = {
643 i::Token::LBRACE, 644 i::Token::LBRACE,
644 i::Token::IDENTIFIER, 645 i::Token::IDENTIFIER,
645 i::Token::IDENTIFIER, 646 i::Token::IDENTIFIER,
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 // The end position of a token is one position after the last 1042 // The end position of a token is one position after the last
1042 // character belonging to that token. 1043 // character belonging to that token.
1043 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); 1044 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen);
1044 } 1045 }
1045 } 1046 }
1046 1047
1047 1048
1048 i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) { 1049 i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
1049 i::Isolate* isolate = i::Isolate::Current(); 1050 i::Isolate* isolate = i::Isolate::Current();
1050 i::Factory* factory = isolate->factory(); 1051 i::Factory* factory = isolate->factory();
1052 const char* message = data->BuildMessage();
1051 i::Handle<i::String> format = v8::Utils::OpenHandle( 1053 i::Handle<i::String> format = v8::Utils::OpenHandle(
1052 *v8::String::New(data->BuildMessage())); 1054 *v8::String::New(message));
1053 i::Vector<const char*> args = data->BuildArgs(); 1055 i::Vector<const char*> args = data->BuildArgs();
1054 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); 1056 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
1055 for (int i = 0; i < args.length(); i++) { 1057 for (int i = 0; i < args.length(); i++) {
1056 i::JSArray::SetElement(args_array, 1058 i::JSArray::SetElement(args_array,
1057 i, 1059 i,
1058 v8::Utils::OpenHandle(*v8::String::New(args[i])), 1060 v8::Utils::OpenHandle(*v8::String::New(args[i])),
1059 NONE, 1061 NONE,
1060 i::kNonStrictMode); 1062 i::kNonStrictMode);
1061 } 1063 }
1062 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); 1064 i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
1063 i::Handle<i::Object> format_fun = 1065 i::Handle<i::Object> format_fun =
1064 i::GetProperty(builtins, "FormatMessage"); 1066 i::GetProperty(builtins, "FormatMessage");
1065 i::Handle<i::Object> arg_handles[] = { format, args_array }; 1067 i::Handle<i::Object> arg_handles[] = { format, args_array };
1066 bool has_exception = false; 1068 bool has_exception = false;
1067 i::Handle<i::Object> result = 1069 i::Handle<i::Object> result =
1068 i::Execution::Call(format_fun, builtins, 2, arg_handles, &has_exception); 1070 i::Execution::Call(format_fun, builtins, 2, arg_handles, &has_exception);
1069 CHECK(!has_exception); 1071 CHECK(!has_exception);
1070 CHECK(result->IsString()); 1072 CHECK(result->IsString());
1073 for (int i = 0; i < args.length(); i++) {
1074 i::DeleteArray(args[i]);
1075 }
1076 i::DeleteArray(args.start());
1077 i::DeleteArray(message);
1071 return i::Handle<i::String>::cast(result); 1078 return i::Handle<i::String>::cast(result);
1072 } 1079 }
1073 1080
1074 1081
1075 enum ParserFlag { 1082 enum ParserFlag {
1076 kAllowLazy, 1083 kAllowLazy,
1077 kAllowNativesSyntax, 1084 kAllowNativesSyntax,
1078 kAllowHarmonyScoping, 1085 kAllowHarmonyScoping,
1079 kAllowModules, 1086 kAllowModules,
1080 kAllowGenerators, 1087 kAllowGenerators,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 for (int j = 0; statement_data[j] != NULL; ++j) { 1279 for (int j = 0; statement_data[j] != NULL; ++j) {
1273 for (int k = 0; termination_data[k] != NULL; ++k) { 1280 for (int k = 0; termination_data[k] != NULL; ++k) {
1274 int kPrefixLen = i::StrLength(context_data[i][0]); 1281 int kPrefixLen = i::StrLength(context_data[i][0]);
1275 int kStatementLen = i::StrLength(statement_data[j]); 1282 int kStatementLen = i::StrLength(statement_data[j]);
1276 int kTerminationLen = i::StrLength(termination_data[k]); 1283 int kTerminationLen = i::StrLength(termination_data[k]);
1277 int kSuffixLen = i::StrLength(context_data[i][1]); 1284 int kSuffixLen = i::StrLength(context_data[i][1]);
1278 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen 1285 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen
1279 + kSuffixLen + i::StrLength("label: for (;;) { }"); 1286 + kSuffixLen + i::StrLength("label: for (;;) { }");
1280 1287
1281 // Plug the source code pieces together. 1288 // Plug the source code pieces together.
1282 i::Vector<char> program = i::Vector<char>::New(kProgramSize + 1); 1289 i::ScopedVector<char> program(kProgramSize + 1);
1283 int length = i::OS::SNPrintF(program, 1290 int length = i::OS::SNPrintF(program,
1284 "label: for (;;) { %s%s%s%s }", 1291 "label: for (;;) { %s%s%s%s }",
1285 context_data[i][0], 1292 context_data[i][0],
1286 statement_data[j], 1293 statement_data[j],
1287 termination_data[k], 1294 termination_data[k],
1288 context_data[i][1]); 1295 context_data[i][1]);
1289 CHECK(length == kProgramSize); 1296 CHECK(length == kProgramSize);
1290 i::Handle<i::String> source = 1297 i::Handle<i::String> source =
1291 factory->NewStringFromAscii(i::CStrVector(program.start())); 1298 factory->NewStringFromAscii(i::CStrVector(program.start()));
1292 TestParserSync(source); 1299 TestParserSync(source);
(...skipping 18 matching lines...) Expand all
1311 " b = function() { \n" 1318 " b = function() { \n"
1312 " 01; \n" 1319 " 01; \n"
1313 " }; \n" 1320 " }; \n"
1314 "}; \n"; 1321 "}; \n";
1315 v8::Script::Compile(v8::String::New(script)); 1322 v8::Script::Compile(v8::String::New(script));
1316 CHECK(try_catch.HasCaught()); 1323 CHECK(try_catch.HasCaught());
1317 v8::String::Utf8Value exception(try_catch.Exception()); 1324 v8::String::Utf8Value exception(try_catch.Exception());
1318 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1319 *exception); 1326 *exception);
1320 } 1327 }
OLDNEW
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/cctest/test-platform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698