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

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

Issue 23534067: bulk replace Isolate::Current in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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-profile-generator.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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 "\"\\n\" --> is eol-comment\nvar y = 37;\n", 132 "\"\\n\" --> is eol-comment\nvar y = 37;\n",
133 "x/* precomment */ --> is eol-comment\nvar y = 37;\n", 133 "x/* precomment */ --> is eol-comment\nvar y = 37;\n",
134 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n", 134 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n",
135 "var x = 42; --> is eol-comment\nvar y = 37;\n", 135 "var x = 42; --> is eol-comment\nvar y = 37;\n",
136 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n", 136 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
137 NULL 137 NULL
138 }; 138 };
139 139
140 // Parser/Scanner needs a stack limit. 140 // Parser/Scanner needs a stack limit.
141 int marker; 141 int marker;
142 i::Isolate::Current()->stack_guard()->SetStackLimit( 142 CcTest::i_isolate()->stack_guard()->SetStackLimit(
143 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 143 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
144 144
145 for (int i = 0; tests[i]; i++) { 145 for (int i = 0; tests[i]; i++) {
146 v8::ScriptData* data = 146 v8::ScriptData* data =
147 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i])); 147 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i]));
148 CHECK(data != NULL && !data->HasError()); 148 CHECK(data != NULL && !data->HasError());
149 delete data; 149 delete data;
150 } 150 }
151 151
152 for (int i = 0; fail_tests[i]; i++) { 152 for (int i = 0; fail_tests[i]; i++) {
(...skipping 18 matching lines...) Expand all
171 size_t length_; 171 size_t length_;
172 }; 172 };
173 173
174 174
175 TEST(Preparsing) { 175 TEST(Preparsing) {
176 v8::Isolate* isolate = CcTest::isolate(); 176 v8::Isolate* isolate = CcTest::isolate();
177 v8::HandleScope handles(isolate); 177 v8::HandleScope handles(isolate);
178 v8::Local<v8::Context> context = v8::Context::New(isolate); 178 v8::Local<v8::Context> context = v8::Context::New(isolate);
179 v8::Context::Scope context_scope(context); 179 v8::Context::Scope context_scope(context);
180 int marker; 180 int marker;
181 i::Isolate::Current()->stack_guard()->SetStackLimit( 181 CcTest::i_isolate()->stack_guard()->SetStackLimit(
182 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 182 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
183 183
184 // Source containing functions that might be lazily compiled and all types 184 // Source containing functions that might be lazily compiled and all types
185 // of symbols (string, propertyName, regexp). 185 // of symbols (string, propertyName, regexp).
186 const char* source = 186 const char* source =
187 "var x = 42;" 187 "var x = 42;"
188 "function foo(a) { return function nolazy(b) { return a + b; } }" 188 "function foo(a) { return function nolazy(b) { return a + b; } }"
189 "function bar(a) { if (a) return function lazy(b) { return b; } }" 189 "function bar(a) { if (a) return function lazy(b) { return b; } }"
190 "var z = {'string': 'string literal', bareword: 'propertyName', " 190 "var z = {'string': 'string literal', bareword: 'propertyName', "
191 " 42: 'number literal', for: 'keyword as propertyName', " 191 " 42: 'number literal', for: 'keyword as propertyName', "
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const char* message = pre_impl->BuildMessage(); 234 const char* message = pre_impl->BuildMessage();
235 pre_impl->BuildArgs(); 235 pre_impl->BuildArgs();
236 CHECK_GT(strlen(message), 0); 236 CHECK_GT(strlen(message), 0);
237 } 237 }
238 238
239 239
240 TEST(StandAlonePreParser) { 240 TEST(StandAlonePreParser) {
241 v8::V8::Initialize(); 241 v8::V8::Initialize();
242 242
243 int marker; 243 int marker;
244 i::Isolate::Current()->stack_guard()->SetStackLimit( 244 CcTest::i_isolate()->stack_guard()->SetStackLimit(
245 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 245 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
246 246
247 const char* programs[] = { 247 const char* programs[] = {
248 "{label: 42}", 248 "{label: 42}",
249 "var x = 42;", 249 "var x = 42;",
250 "function foo(x, y) { return x + y; }", 250 "function foo(x, y) { return x + y; }",
251 "%ArgleBargle(glop);", 251 "%ArgleBargle(glop);",
252 "var x = new new Function('this.x = 42');", 252 "var x = new new Function('this.x = 42');",
253 NULL 253 NULL
254 }; 254 };
255 255
256 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); 256 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
257 for (int i = 0; programs[i]; i++) { 257 for (int i = 0; programs[i]; i++) {
258 const char* program = programs[i]; 258 const char* program = programs[i];
259 i::Utf8ToUtf16CharacterStream stream( 259 i::Utf8ToUtf16CharacterStream stream(
260 reinterpret_cast<const i::byte*>(program), 260 reinterpret_cast<const i::byte*>(program),
261 static_cast<unsigned>(strlen(program))); 261 static_cast<unsigned>(strlen(program)));
262 i::CompleteParserRecorder log; 262 i::CompleteParserRecorder log;
263 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); 263 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
264 scanner.Initialize(&stream); 264 scanner.Initialize(&stream);
265 265
266 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); 266 v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
267 preparser.set_allow_lazy(true); 267 preparser.set_allow_lazy(true);
268 preparser.set_allow_natives_syntax(true); 268 preparser.set_allow_natives_syntax(true);
269 v8::preparser::PreParser::PreParseResult result = 269 v8::preparser::PreParser::PreParseResult result =
270 preparser.PreParseProgram(); 270 preparser.PreParseProgram();
271 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); 271 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result);
272 i::ScriptDataImpl data(log.ExtractData()); 272 i::ScriptDataImpl data(log.ExtractData());
273 CHECK(!data.has_error()); 273 CHECK(!data.has_error());
274 } 274 }
275 } 275 }
276 276
277 277
278 TEST(StandAlonePreParserNoNatives) { 278 TEST(StandAlonePreParserNoNatives) {
279 v8::V8::Initialize(); 279 v8::V8::Initialize();
280 280
281 int marker; 281 int marker;
282 i::Isolate::Current()->stack_guard()->SetStackLimit( 282 CcTest::i_isolate()->stack_guard()->SetStackLimit(
283 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 283 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
284 284
285 const char* programs[] = { 285 const char* programs[] = {
286 "%ArgleBargle(glop);", 286 "%ArgleBargle(glop);",
287 "var x = %_IsSmi(42);", 287 "var x = %_IsSmi(42);",
288 NULL 288 NULL
289 }; 289 };
290 290
291 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); 291 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
292 for (int i = 0; programs[i]; i++) { 292 for (int i = 0; programs[i]; i++) {
293 const char* program = programs[i]; 293 const char* program = programs[i];
294 i::Utf8ToUtf16CharacterStream stream( 294 i::Utf8ToUtf16CharacterStream stream(
295 reinterpret_cast<const i::byte*>(program), 295 reinterpret_cast<const i::byte*>(program),
296 static_cast<unsigned>(strlen(program))); 296 static_cast<unsigned>(strlen(program)));
297 i::CompleteParserRecorder log; 297 i::CompleteParserRecorder log;
298 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); 298 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
299 scanner.Initialize(&stream); 299 scanner.Initialize(&stream);
300 300
301 // Preparser defaults to disallowing natives syntax. 301 // Preparser defaults to disallowing natives syntax.
302 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); 302 v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
303 preparser.set_allow_lazy(true); 303 preparser.set_allow_lazy(true);
304 v8::preparser::PreParser::PreParseResult result = 304 v8::preparser::PreParser::PreParseResult result =
305 preparser.PreParseProgram(); 305 preparser.PreParseProgram();
306 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); 306 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result);
307 i::ScriptDataImpl data(log.ExtractData()); 307 i::ScriptDataImpl data(log.ExtractData());
308 // Data contains syntax error. 308 // Data contains syntax error.
309 CHECK(data.has_error()); 309 CHECK(data.has_error());
310 } 310 }
311 } 311 }
312 312
313 313
314 TEST(RegressChromium62639) { 314 TEST(RegressChromium62639) {
315 v8::V8::Initialize(); 315 v8::V8::Initialize();
316 i::Isolate* isolate = i::Isolate::Current(); 316 i::Isolate* isolate = CcTest::i_isolate();
317 317
318 int marker; 318 int marker;
319 isolate->stack_guard()->SetStackLimit( 319 isolate->stack_guard()->SetStackLimit(
320 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 320 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
321 321
322 const char* program = "var x = 'something';\n" 322 const char* program = "var x = 'something';\n"
323 "escape: function() {}"; 323 "escape: function() {}";
324 // Fails parsing expecting an identifier after "function". 324 // Fails parsing expecting an identifier after "function".
325 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 325 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
326 // and then used the invalid currently scanned literal. This always 326 // and then used the invalid currently scanned literal. This always
327 // failed in debug mode, and sometimes crashed in release mode. 327 // failed in debug mode, and sometimes crashed in release mode.
328 328
329 i::Utf8ToUtf16CharacterStream stream( 329 i::Utf8ToUtf16CharacterStream stream(
330 reinterpret_cast<const i::byte*>(program), 330 reinterpret_cast<const i::byte*>(program),
331 static_cast<unsigned>(strlen(program))); 331 static_cast<unsigned>(strlen(program)));
332 i::ScriptDataImpl* data = i::PreParserApi::PreParse(isolate, &stream); 332 i::ScriptDataImpl* data = i::PreParserApi::PreParse(isolate, &stream);
333 CHECK(data->HasError()); 333 CHECK(data->HasError());
334 delete data; 334 delete data;
335 } 335 }
336 336
337 337
338 TEST(Regress928) { 338 TEST(Regress928) {
339 v8::V8::Initialize(); 339 v8::V8::Initialize();
340 i::Isolate* isolate = i::Isolate::Current(); 340 i::Isolate* isolate = CcTest::i_isolate();
341 i::Factory* factory = isolate->factory(); 341 i::Factory* factory = isolate->factory();
342 342
343 // Preparsing didn't consider the catch clause of a try statement 343 // Preparsing didn't consider the catch clause of a try statement
344 // as with-content, which made it assume that a function inside 344 // as with-content, which made it assume that a function inside
345 // the block could be lazily compiled, and an extra, unexpected, 345 // the block could be lazily compiled, and an extra, unexpected,
346 // entry was added to the data. 346 // entry was added to the data.
347 int marker; 347 int marker;
348 isolate->stack_guard()->SetStackLimit( 348 isolate->stack_guard()->SetStackLimit(
349 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 349 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
350 350
(...skipping 26 matching lines...) Expand all
377 CHECK(entry2.is_valid()); 377 CHECK(entry2.is_valid());
378 CHECK_EQ('}', program[entry2.end_pos() - 1]); 378 CHECK_EQ('}', program[entry2.end_pos() - 1]);
379 delete data; 379 delete data;
380 } 380 }
381 381
382 382
383 TEST(PreParseOverflow) { 383 TEST(PreParseOverflow) {
384 v8::V8::Initialize(); 384 v8::V8::Initialize();
385 385
386 int marker; 386 int marker;
387 i::Isolate::Current()->stack_guard()->SetStackLimit( 387 CcTest::i_isolate()->stack_guard()->SetStackLimit(
388 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 388 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
389 389
390 size_t kProgramSize = 1024 * 1024; 390 size_t kProgramSize = 1024 * 1024;
391 i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1)); 391 i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1));
392 memset(*program, '(', kProgramSize); 392 memset(*program, '(', kProgramSize);
393 program[kProgramSize] = '\0'; 393 program[kProgramSize] = '\0';
394 394
395 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); 395 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
396 396
397 i::Utf8ToUtf16CharacterStream stream( 397 i::Utf8ToUtf16CharacterStream stream(
398 reinterpret_cast<const i::byte*>(*program), 398 reinterpret_cast<const i::byte*>(*program),
399 static_cast<unsigned>(kProgramSize)); 399 static_cast<unsigned>(kProgramSize));
400 i::CompleteParserRecorder log; 400 i::CompleteParserRecorder log;
401 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); 401 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
402 scanner.Initialize(&stream); 402 scanner.Initialize(&stream);
403 403
404 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); 404 v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
405 preparser.set_allow_lazy(true); 405 preparser.set_allow_lazy(true);
406 v8::preparser::PreParser::PreParseResult result = 406 v8::preparser::PreParser::PreParseResult result =
407 preparser.PreParseProgram(); 407 preparser.PreParseProgram();
408 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); 408 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result);
409 } 409 }
410 410
411 411
(...skipping 18 matching lines...) Expand all
430 430
431 431
432 #define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2)) 432 #define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2))
433 433
434 void TestCharacterStream(const char* ascii_source, 434 void TestCharacterStream(const char* ascii_source,
435 unsigned length, 435 unsigned length,
436 unsigned start = 0, 436 unsigned start = 0,
437 unsigned end = 0) { 437 unsigned end = 0) {
438 if (end == 0) end = length; 438 if (end == 0) end = length;
439 unsigned sub_length = end - start; 439 unsigned sub_length = end - start;
440 i::Isolate* isolate = i::Isolate::Current(); 440 i::Isolate* isolate = CcTest::i_isolate();
441 i::Factory* factory = isolate->factory(); 441 i::Factory* factory = isolate->factory();
442 i::HandleScope test_scope(isolate); 442 i::HandleScope test_scope(isolate);
443 i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]); 443 i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]);
444 for (unsigned i = 0; i < length; i++) { 444 for (unsigned i = 0; i < length; i++) {
445 uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]); 445 uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]);
446 } 446 }
447 i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length)); 447 i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length));
448 i::Handle<i::String> ascii_string( 448 i::Handle<i::String> ascii_string(
449 factory->NewStringFromAscii(ascii_vector)); 449 factory->NewStringFromAscii(ascii_vector));
450 TestExternalResource resource(*uc16_buffer, length); 450 TestExternalResource resource(*uc16_buffer, length);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 CHECK_EQU(i, stream.pos()); 612 CHECK_EQU(i, stream.pos());
613 } 613 }
614 } 614 }
615 615
616 #undef CHECK_EQU 616 #undef CHECK_EQU
617 617
618 void TestStreamScanner(i::Utf16CharacterStream* stream, 618 void TestStreamScanner(i::Utf16CharacterStream* stream,
619 i::Token::Value* expected_tokens, 619 i::Token::Value* expected_tokens,
620 int skip_pos = 0, // Zero means not skipping. 620 int skip_pos = 0, // Zero means not skipping.
621 int skip_to = 0) { 621 int skip_to = 0) {
622 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); 622 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
623 scanner.Initialize(stream); 623 scanner.Initialize(stream);
624 624
625 int i = 0; 625 int i = 0;
626 do { 626 do {
627 i::Token::Value expected = expected_tokens[i]; 627 i::Token::Value expected = expected_tokens[i];
628 i::Token::Value actual = scanner.Next(); 628 i::Token::Value actual = scanner.Next();
629 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); 629 CHECK_EQ(i::Token::String(expected), i::Token::String(actual));
630 if (scanner.location().end_pos == skip_pos) { 630 if (scanner.location().end_pos == skip_pos) {
631 scanner.SeekForward(skip_to); 631 scanner.SeekForward(skip_to);
632 } 632 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 static_cast<unsigned>(strlen(str3))); 694 static_cast<unsigned>(strlen(str3)));
695 TestStreamScanner(&stream3, expectations3, 1, 1 + i); 695 TestStreamScanner(&stream3, expectations3, 1, 1 + i);
696 } 696 }
697 } 697 }
698 698
699 699
700 void TestScanRegExp(const char* re_source, const char* expected) { 700 void TestScanRegExp(const char* re_source, const char* expected) {
701 i::Utf8ToUtf16CharacterStream stream( 701 i::Utf8ToUtf16CharacterStream stream(
702 reinterpret_cast<const i::byte*>(re_source), 702 reinterpret_cast<const i::byte*>(re_source),
703 static_cast<unsigned>(strlen(re_source))); 703 static_cast<unsigned>(strlen(re_source)));
704 i::Scanner scanner(i::Isolate::Current()->unicode_cache()); 704 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
705 scanner.Initialize(&stream); 705 scanner.Initialize(&stream);
706 706
707 i::Token::Value start = scanner.peek(); 707 i::Token::Value start = scanner.peek();
708 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); 708 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV);
709 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); 709 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV));
710 scanner.Next(); // Current token is now the regexp literal. 710 scanner.Next(); // Current token is now the regexp literal.
711 CHECK(scanner.is_literal_ascii()); 711 CHECK(scanner.is_literal_ascii());
712 i::Vector<const char> actual = scanner.literal_ascii_string(); 712 i::Vector<const char> actual = scanner.literal_ascii_string();
713 for (int i = 0; i < actual.length(); i++) { 713 for (int i = 0; i < actual.length(); i++) {
714 CHECK_NE('\0', expected[i]); 714 CHECK_NE('\0', expected[i]);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, 983 i::FUNCTION_SCOPE, i::CLASSIC_MODE },
984 { " 'foo';\n" 984 { " 'foo';\n"
985 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", 985 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();",
986 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, 986 i::FUNCTION_SCOPE, i::CLASSIC_MODE },
987 { " 'foo';\n" 987 { " 'foo';\n"
988 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", 988 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();",
989 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, 989 i::FUNCTION_SCOPE, i::CLASSIC_MODE },
990 { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE } 990 { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE }
991 }; 991 };
992 992
993 i::Isolate* isolate = i::Isolate::Current(); 993 i::Isolate* isolate = CcTest::i_isolate();
994 i::Factory* factory = isolate->factory(); 994 i::Factory* factory = isolate->factory();
995 995
996 v8::HandleScope handles(CcTest::isolate()); 996 v8::HandleScope handles(CcTest::isolate());
997 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 997 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
998 v8::Context::Scope context_scope(context); 998 v8::Context::Scope context_scope(context);
999 999
1000 int marker; 1000 int marker;
1001 isolate->stack_guard()->SetStackLimit( 1001 isolate->stack_guard()->SetStackLimit(
1002 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 1002 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
1003 1003
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type); 1041 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type);
1042 CHECK_EQ(inner_scope->start_position(), kPrefixLen); 1042 CHECK_EQ(inner_scope->start_position(), kPrefixLen);
1043 // The end position of a token is one position after the last 1043 // The end position of a token is one position after the last
1044 // character belonging to that token. 1044 // character belonging to that token.
1045 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); 1045 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen);
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 1049
1050 i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) { 1050 i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
1051 i::Isolate* isolate = i::Isolate::Current(); 1051 i::Isolate* isolate = CcTest::i_isolate();
1052 i::Factory* factory = isolate->factory(); 1052 i::Factory* factory = isolate->factory();
1053 const char* message = data->BuildMessage(); 1053 const char* message = data->BuildMessage();
1054 i::Handle<i::String> format = v8::Utils::OpenHandle( 1054 i::Handle<i::String> format = v8::Utils::OpenHandle(
1055 *v8::String::New(message)); 1055 *v8::String::New(message));
1056 i::Vector<const char*> args = data->BuildArgs(); 1056 i::Vector<const char*> args = data->BuildArgs();
1057 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); 1057 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
1058 for (int i = 0; i < args.length(); i++) { 1058 for (int i = 0; i < args.length(); i++) {
1059 i::JSArray::SetElement(args_array, 1059 i::JSArray::SetElement(args_array,
1060 i, 1060 i,
1061 v8::Utils::OpenHandle(*v8::String::New(args[i])), 1061 v8::Utils::OpenHandle(*v8::String::New(args[i])),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 kAllowNativesSyntax)); \ 1103 kAllowNativesSyntax)); \
1104 parser.set_allow_harmony_scoping(checkParserFlag(flags, \ 1104 parser.set_allow_harmony_scoping(checkParserFlag(flags, \
1105 kAllowHarmonyScoping)); \ 1105 kAllowHarmonyScoping)); \
1106 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \ 1106 parser.set_allow_modules(checkParserFlag(flags, kAllowModules)); \
1107 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); \ 1107 parser.set_allow_generators(checkParserFlag(flags, kAllowGenerators)); \
1108 parser.set_allow_for_of(checkParserFlag(flags, kAllowForOf)); \ 1108 parser.set_allow_for_of(checkParserFlag(flags, kAllowForOf)); \
1109 parser.set_allow_harmony_numeric_literals( \ 1109 parser.set_allow_harmony_numeric_literals( \
1110 checkParserFlag(flags, kAllowHarmonyNumericLiterals)); 1110 checkParserFlag(flags, kAllowHarmonyNumericLiterals));
1111 1111
1112 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { 1112 void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) {
1113 i::Isolate* isolate = i::Isolate::Current(); 1113 i::Isolate* isolate = CcTest::i_isolate();
1114 i::Factory* factory = isolate->factory(); 1114 i::Factory* factory = isolate->factory();
1115 1115
1116 uintptr_t stack_limit = isolate->stack_guard()->real_climit(); 1116 uintptr_t stack_limit = isolate->stack_guard()->real_climit();
1117 1117
1118 // Preparse the data. 1118 // Preparse the data.
1119 i::CompleteParserRecorder log; 1119 i::CompleteParserRecorder log;
1120 { 1120 {
1121 i::Scanner scanner(isolate->unicode_cache()); 1121 i::Scanner scanner(isolate->unicode_cache());
1122 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 1122 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
1123 v8::preparser::PreParser preparser(&scanner, &log, stack_limit); 1123 v8::preparser::PreParser preparser(&scanner, &log, stack_limit);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1257
1258 const char* termination_data[] = { 1258 const char* termination_data[] = {
1259 "", 1259 "",
1260 ";", 1260 ";",
1261 "\n", 1261 "\n",
1262 ";\n", 1262 ";\n",
1263 "\n;", 1263 "\n;",
1264 NULL 1264 NULL
1265 }; 1265 };
1266 1266
1267 i::Isolate* isolate = i::Isolate::Current(); 1267 i::Isolate* isolate = CcTest::i_isolate();
1268 i::Factory* factory = isolate->factory(); 1268 i::Factory* factory = isolate->factory();
1269 1269
1270 v8::HandleScope handles(CcTest::isolate()); 1270 v8::HandleScope handles(CcTest::isolate());
1271 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 1271 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
1272 v8::Context::Scope context_scope(context); 1272 v8::Context::Scope context_scope(context);
1273 1273
1274 int marker; 1274 int marker;
1275 isolate->stack_guard()->SetStackLimit( 1275 isolate->stack_guard()->SetStackLimit(
1276 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 1276 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
1277 1277
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 " b = function() { \n" 1318 " b = function() { \n"
1319 " 01; \n" 1319 " 01; \n"
1320 " }; \n" 1320 " }; \n"
1321 "}; \n"; 1321 "}; \n";
1322 v8::Script::Compile(v8::String::New(script)); 1322 v8::Script::Compile(v8::String::New(script));
1323 CHECK(try_catch.HasCaught()); 1323 CHECK(try_catch.HasCaught());
1324 v8::String::Utf8Value exception(try_catch.Exception()); 1324 v8::String::Utf8Value exception(try_catch.Exception());
1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1326 *exception); 1326 *exception);
1327 } 1327 }
OLDNEW
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698