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

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

Issue 145773008: A64: Synchronize with r17104. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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-time.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 scanner.Initialize(&stream); 100 scanner.Initialize(&stream);
101 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); 101 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next());
102 CHECK_EQ(i::Token::EOS, scanner.Next()); 102 CHECK_EQ(i::Token::EOS, scanner.Next());
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 107
108 TEST(ScanHTMLEndComments) { 108 TEST(ScanHTMLEndComments) {
109 v8::V8::Initialize(); 109 v8::V8::Initialize();
110 v8::Isolate* isolate = CcTest::isolate();
110 111
111 // Regression test. See: 112 // Regression test. See:
112 // http://code.google.com/p/chromium/issues/detail?id=53548 113 // http://code.google.com/p/chromium/issues/detail?id=53548
113 // Tests that --> is correctly interpreted as comment-to-end-of-line if there 114 // Tests that --> is correctly interpreted as comment-to-end-of-line if there
114 // is only whitespace before it on the line (with comments considered as 115 // is only whitespace before it on the line (with comments considered as
115 // whitespace, even a multiline-comment containing a newline). 116 // whitespace, even a multiline-comment containing a newline).
116 // This was not the case if it occurred before the first real token 117 // This was not the case if it occurred before the first real token
117 // in the input. 118 // in the input.
118 const char* tests[] = { 119 const char* tests[] = {
119 // Before first real token. 120 // Before first real token.
(...skipping 17 matching lines...) Expand all
137 NULL 138 NULL
138 }; 139 };
139 140
140 // Parser/Scanner needs a stack limit. 141 // Parser/Scanner needs a stack limit.
141 int marker; 142 int marker;
142 CcTest::i_isolate()->stack_guard()->SetStackLimit( 143 CcTest::i_isolate()->stack_guard()->SetStackLimit(
143 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 144 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
144 145
145 for (int i = 0; tests[i]; i++) { 146 for (int i = 0; tests[i]; i++) {
146 v8::ScriptData* data = 147 v8::ScriptData* data =
147 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i])); 148 v8::ScriptData::PreCompile(isolate, tests[i], i::StrLength(tests[i]));
148 CHECK(data != NULL && !data->HasError()); 149 CHECK(data != NULL && !data->HasError());
149 delete data; 150 delete data;
150 } 151 }
151 152
152 for (int i = 0; fail_tests[i]; i++) { 153 for (int i = 0; fail_tests[i]; i++) {
153 v8::ScriptData* data = 154 v8::ScriptData* data = v8::ScriptData::PreCompile(
154 v8::ScriptData::PreCompile(fail_tests[i], i::StrLength(fail_tests[i])); 155 isolate, fail_tests[i], i::StrLength(fail_tests[i]));
155 CHECK(data == NULL || data->HasError()); 156 CHECK(data == NULL || data->HasError());
156 delete data; 157 delete data;
157 } 158 }
158 } 159 }
159 160
160 161
161 class ScriptResource : public v8::String::ExternalAsciiStringResource { 162 class ScriptResource : public v8::String::ExternalAsciiStringResource {
162 public: 163 public:
163 ScriptResource(const char* data, size_t length) 164 ScriptResource(const char* data, size_t length)
164 : data_(data), length_(length) { } 165 : data_(data), length_(length) { }
(...skipping 27 matching lines...) Expand all
192 " f\\u006fr: 'keyword propertyname with escape'};" 193 " f\\u006fr: 'keyword propertyname with escape'};"
193 "var v = /RegExp Literal/;" 194 "var v = /RegExp Literal/;"
194 "var w = /RegExp Literal\\u0020With Escape/gin;" 195 "var w = /RegExp Literal\\u0020With Escape/gin;"
195 "var y = { get getter() { return 42; }, " 196 "var y = { get getter() { return 42; }, "
196 " set setter(v) { this.value = v; }};"; 197 " set setter(v) { this.value = v; }};";
197 int source_length = i::StrLength(source); 198 int source_length = i::StrLength(source);
198 const char* error_source = "var x = y z;"; 199 const char* error_source = "var x = y z;";
199 int error_source_length = i::StrLength(error_source); 200 int error_source_length = i::StrLength(error_source);
200 201
201 v8::ScriptData* preparse = 202 v8::ScriptData* preparse =
202 v8::ScriptData::PreCompile(source, source_length); 203 v8::ScriptData::PreCompile(isolate, source, source_length);
203 CHECK(!preparse->HasError()); 204 CHECK(!preparse->HasError());
204 bool lazy_flag = i::FLAG_lazy; 205 bool lazy_flag = i::FLAG_lazy;
205 { 206 {
206 i::FLAG_lazy = true; 207 i::FLAG_lazy = true;
207 ScriptResource* resource = new ScriptResource(source, source_length); 208 ScriptResource* resource = new ScriptResource(source, source_length);
208 v8::Local<v8::String> script_source = v8::String::NewExternal(resource); 209 v8::Local<v8::String> script_source = v8::String::NewExternal(resource);
209 v8::Script::Compile(script_source, NULL, preparse); 210 v8::Script::Compile(script_source, NULL, preparse);
210 } 211 }
211 212
212 { 213 {
213 i::FLAG_lazy = false; 214 i::FLAG_lazy = false;
214 215
215 ScriptResource* resource = new ScriptResource(source, source_length); 216 ScriptResource* resource = new ScriptResource(source, source_length);
216 v8::Local<v8::String> script_source = v8::String::NewExternal(resource); 217 v8::Local<v8::String> script_source = v8::String::NewExternal(resource);
217 v8::Script::New(script_source, NULL, preparse, v8::Local<v8::String>()); 218 v8::Script::New(script_source, NULL, preparse, v8::Local<v8::String>());
218 } 219 }
219 delete preparse; 220 delete preparse;
220 i::FLAG_lazy = lazy_flag; 221 i::FLAG_lazy = lazy_flag;
221 222
222 // Syntax error. 223 // Syntax error.
223 v8::ScriptData* error_preparse = 224 v8::ScriptData* error_preparse =
224 v8::ScriptData::PreCompile(error_source, error_source_length); 225 v8::ScriptData::PreCompile(isolate, error_source, error_source_length);
225 CHECK(error_preparse->HasError()); 226 CHECK(error_preparse->HasError());
226 i::ScriptDataImpl *pre_impl = 227 i::ScriptDataImpl *pre_impl =
227 reinterpret_cast<i::ScriptDataImpl*>(error_preparse); 228 reinterpret_cast<i::ScriptDataImpl*>(error_preparse);
228 i::Scanner::Location error_location = 229 i::Scanner::Location error_location =
229 pre_impl->MessageLocation(); 230 pre_impl->MessageLocation();
230 // Error is at "z" in source, location 10..11. 231 // Error is at "z" in source, location 10..11.
231 CHECK_EQ(10, error_location.beg_pos); 232 CHECK_EQ(10, error_location.beg_pos);
232 CHECK_EQ(11, error_location.end_pos); 233 CHECK_EQ(11, error_location.end_pos);
233 // Should not crash. 234 // Should not crash.
234 const char* message = pre_impl->BuildMessage(); 235 const char* message = pre_impl->BuildMessage();
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 i::Handle<i::String> source( 1021 i::Handle<i::String> source(
1021 factory->NewStringFromUtf8(i::CStrVector(program.start()))); 1022 factory->NewStringFromUtf8(i::CStrVector(program.start())));
1022 CHECK_EQ(source->length(), kProgramSize); 1023 CHECK_EQ(source->length(), kProgramSize);
1023 i::Handle<i::Script> script = factory->NewScript(source); 1024 i::Handle<i::Script> script = factory->NewScript(source);
1024 i::CompilationInfoWithZone info(script); 1025 i::CompilationInfoWithZone info(script);
1025 i::Parser parser(&info); 1026 i::Parser parser(&info);
1026 parser.set_allow_lazy(true); 1027 parser.set_allow_lazy(true);
1027 parser.set_allow_harmony_scoping(true); 1028 parser.set_allow_harmony_scoping(true);
1028 info.MarkAsGlobal(); 1029 info.MarkAsGlobal();
1029 info.SetLanguageMode(source_data[i].language_mode); 1030 info.SetLanguageMode(source_data[i].language_mode);
1030 i::FunctionLiteral* function = parser.ParseProgram(); 1031 parser.Parse();
1031 CHECK(function != NULL); 1032 CHECK(info.function() != NULL);
1032 1033
1033 // Check scope types and positions. 1034 // Check scope types and positions.
1034 i::Scope* scope = function->scope(); 1035 i::Scope* scope = info.function()->scope();
1035 CHECK(scope->is_global_scope()); 1036 CHECK(scope->is_global_scope());
1036 CHECK_EQ(scope->start_position(), 0); 1037 CHECK_EQ(scope->start_position(), 0);
1037 CHECK_EQ(scope->end_position(), kProgramSize); 1038 CHECK_EQ(scope->end_position(), kProgramSize);
1038 CHECK_EQ(scope->inner_scopes()->length(), 1); 1039 CHECK_EQ(scope->inner_scopes()->length(), 1);
1039 1040
1040 i::Scope* inner_scope = scope->inner_scopes()->at(0); 1041 i::Scope* inner_scope = scope->inner_scopes()->at(0);
1041 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type); 1042 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type);
1042 CHECK_EQ(inner_scope->start_position(), kPrefixLen); 1043 CHECK_EQ(inner_scope->start_position(), kPrefixLen);
1043 // The end position of a token is one position after the last 1044 // The end position of a token is one position after the last
1044 // character belonging to that token. 1045 // character belonging to that token.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 i::ScriptDataImpl data(log.ExtractData()); 1131 i::ScriptDataImpl data(log.ExtractData());
1131 1132
1132 // Parse the data 1133 // Parse the data
1133 i::FunctionLiteral* function; 1134 i::FunctionLiteral* function;
1134 { 1135 {
1135 i::Handle<i::Script> script = factory->NewScript(source); 1136 i::Handle<i::Script> script = factory->NewScript(source);
1136 i::CompilationInfoWithZone info(script); 1137 i::CompilationInfoWithZone info(script);
1137 i::Parser parser(&info); 1138 i::Parser parser(&info);
1138 SET_PARSER_FLAGS(parser, flags); 1139 SET_PARSER_FLAGS(parser, flags);
1139 info.MarkAsGlobal(); 1140 info.MarkAsGlobal();
1140 function = parser.ParseProgram(); 1141 parser.Parse();
1142 function = info.function();
1141 } 1143 }
1142 1144
1143 // Check that preparsing fails iff parsing fails. 1145 // Check that preparsing fails iff parsing fails.
1144 if (function == NULL) { 1146 if (function == NULL) {
1145 // Extract exception from the parser. 1147 // Extract exception from the parser.
1146 CHECK(isolate->has_pending_exception()); 1148 CHECK(isolate->has_pending_exception());
1147 i::MaybeObject* maybe_object = isolate->pending_exception(); 1149 i::MaybeObject* maybe_object = isolate->pending_exception();
1148 i::JSObject* exception = NULL; 1150 i::JSObject* exception = NULL;
1149 CHECK(maybe_object->To(&exception)); 1151 CHECK(maybe_object->To(&exception));
1150 i::Handle<i::JSObject> exception_handle(exception); 1152 i::Handle<i::JSObject> exception_handle(exception);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 " b = function() { \n" 1320 " b = function() { \n"
1319 " 01; \n" 1321 " 01; \n"
1320 " }; \n" 1322 " }; \n"
1321 "}; \n"; 1323 "}; \n";
1322 v8::Script::Compile(v8::String::New(script)); 1324 v8::Script::Compile(v8::String::New(script));
1323 CHECK(try_catch.HasCaught()); 1325 CHECK(try_catch.HasCaught());
1324 v8::String::Utf8Value exception(try_catch.Exception()); 1326 v8::String::Utf8Value exception(try_catch.Exception());
1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1327 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1326 *exception); 1328 *exception);
1327 } 1329 }
OLDNEW
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/cctest/test-time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698