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

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

Issue 8386072: Fix gcc-4.6 warnings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 CHECK(error_preparse->HasError()); 222 CHECK(error_preparse->HasError());
223 i::ScriptDataImpl *pre_impl = 223 i::ScriptDataImpl *pre_impl =
224 reinterpret_cast<i::ScriptDataImpl*>(error_preparse); 224 reinterpret_cast<i::ScriptDataImpl*>(error_preparse);
225 i::Scanner::Location error_location = 225 i::Scanner::Location error_location =
226 pre_impl->MessageLocation(); 226 pre_impl->MessageLocation();
227 // Error is at "z" in source, location 10..11. 227 // Error is at "z" in source, location 10..11.
228 CHECK_EQ(10, error_location.beg_pos); 228 CHECK_EQ(10, error_location.beg_pos);
229 CHECK_EQ(11, error_location.end_pos); 229 CHECK_EQ(11, error_location.end_pos);
230 // Should not crash. 230 // Should not crash.
231 const char* message = pre_impl->BuildMessage(); 231 const char* message = pre_impl->BuildMessage();
232 i::Vector<const char*> args = pre_impl->BuildArgs(); 232 i::Vector<const char*> args(pre_impl->BuildArgs());
233 CHECK_GT(strlen(message), 0); 233 CHECK_GT(strlen(message), 0);
234 } 234 }
235 235
236 236
237 TEST(StandAlonePreParser) { 237 TEST(StandAlonePreParser) {
238 v8::V8::Initialize(); 238 v8::V8::Initialize();
239 239
240 int marker; 240 int marker;
241 i::Isolate::Current()->stack_guard()->SetStackLimit( 241 i::Isolate::Current()->stack_guard()->SetStackLimit(
242 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 242 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 int marker; 837 int marker;
838 i::Isolate::Current()->stack_guard()->SetStackLimit( 838 i::Isolate::Current()->stack_guard()->SetStackLimit(
839 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 839 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
840 840
841 for (int i = 0; source_data[i].outer_prefix; i++) { 841 for (int i = 0; source_data[i].outer_prefix; i++) {
842 int kPrefixLen = i::StrLength(source_data[i].outer_prefix); 842 int kPrefixLen = i::StrLength(source_data[i].outer_prefix);
843 int kInnerLen = i::StrLength(source_data[i].inner_source); 843 int kInnerLen = i::StrLength(source_data[i].inner_source);
844 int kSuffixLen = i::StrLength(source_data[i].outer_suffix); 844 int kSuffixLen = i::StrLength(source_data[i].outer_suffix);
845 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; 845 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen;
846 i::Vector<char> program = i::Vector<char>::New(kProgramSize + 1); 846 i::Vector<char> program = i::Vector<char>::New(kProgramSize + 1);
847 int length; 847 int length = i::OS::SNPrintF(program, "%s%s%s",
848 length = i::OS::SNPrintF(program, "%s%s%s", 848 source_data[i].outer_prefix,
849 source_data[i].outer_prefix, 849 source_data[i].inner_source,
850 source_data[i].inner_source, 850 source_data[i].outer_suffix);
851 source_data[i].outer_suffix); 851 CHECK(length == kProgramSize);
852 ASSERT(length == kProgramSize);
853 852
854 // Parse program source. 853 // Parse program source.
855 i::Handle<i::String> source( 854 i::Handle<i::String> source(
856 FACTORY->NewStringFromAscii(i::CStrVector(program.start()))); 855 FACTORY->NewStringFromAscii(i::CStrVector(program.start())));
857 i::Handle<i::Script> script = FACTORY->NewScript(source); 856 i::Handle<i::Script> script = FACTORY->NewScript(source);
858 i::Parser parser(script, false, NULL, NULL); 857 i::Parser parser(script, false, NULL, NULL);
859 parser.SetHarmonyScoping(true); 858 parser.SetHarmonyScoping(true);
860 i::FunctionLiteral* function = 859 i::FunctionLiteral* function =
861 parser.ParseProgram(source, true, i::kNonStrictMode); 860 parser.ParseProgram(source, true, i::kNonStrictMode);
862 ASSERT(function != NULL); 861 ASSERT(function != NULL);
863 862
864 // Check scope types and positions. 863 // Check scope types and positions.
865 i::Scope* scope = function->scope(); 864 i::Scope* scope = function->scope();
866 CHECK(scope->is_global_scope()); 865 CHECK(scope->is_global_scope());
867 CHECK_EQ(scope->start_position(), 0); 866 CHECK_EQ(scope->start_position(), 0);
868 CHECK_EQ(scope->end_position(), kProgramSize); 867 CHECK_EQ(scope->end_position(), kProgramSize);
869 CHECK_EQ(scope->inner_scopes()->length(), 1); 868 CHECK_EQ(scope->inner_scopes()->length(), 1);
870 869
871 i::Scope* inner_scope = scope->inner_scopes()->at(0); 870 i::Scope* inner_scope = scope->inner_scopes()->at(0);
872 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); 871 CHECK_EQ(inner_scope->type(), source_data[i].scope_type);
873 CHECK_EQ(inner_scope->start_position(), kPrefixLen); 872 CHECK_EQ(inner_scope->start_position(), kPrefixLen);
874 // The end position of a token is one position after the last 873 // The end position of a token is one position after the last
875 // character belonging to that token. 874 // character belonging to that token.
876 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); 875 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen);
877 } 876 }
878 } 877 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698