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-api.cc

Issue 316173002: Handle "//# sourceURL" comments in the Parser instead of the JS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 6 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
« src/scanner.cc ('K') | « src/vector.h ('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 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 17612 matching lines...) Expand 10 before | Expand all | Expand 10 after
17623 17623
17624 const char *source = 17624 const char *source =
17625 "function outer() {\n" 17625 "function outer() {\n"
17626 "function bar() {\n" 17626 "function bar() {\n"
17627 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" 17627 " AnalyzeStackOfDynamicScriptWithSourceURL();\n"
17628 "}\n" 17628 "}\n"
17629 "function foo() {\n" 17629 "function foo() {\n"
17630 "\n" 17630 "\n"
17631 " bar();\n" 17631 " bar();\n"
17632 "}\n" 17632 "}\n"
17633 "%s\n"
17633 "foo();\n" 17634 "foo();\n"
17634 "}\n" 17635 "}\n"
17635 "outer()\n%s"; 17636 "outer()\n%s";
17636 17637
17637 i::ScopedVector<char> code(1024); 17638 i::ScopedVector<char> code(1024);
17638 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); 17639 i::OS::SNPrintF(code, source, "", "//# sourceURL=source_url");
17639 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); 17640 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17640 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); 17641 i::OS::SNPrintF(code, source, "", "//@ sourceURL=source_url");
17642 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17643
17644 // More whitespace.
17645 i::OS::SNPrintF(code, source, "",
17646 "//# \t sourceURL \t = \t source_url\t\t ");
17647 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17648
17649 // Two source URLs
17650 i::OS::SNPrintF(code, source,
17651 "//# sourceURL=ignore_this", "//# sourceURL=source_url");
17652 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17653
17654 // Source URL in the middle of the script.
17655 i::OS::SNPrintF(code, source, "//# sourceURL=source_url", "");
17641 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); 17656 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17642 } 17657 }
17643 17658
17644 17659
17645 TEST(DynamicWithSourceURLInStackTraceString) { 17660 TEST(DynamicWithSourceURLInStackTraceString) {
17646 LocalContext context; 17661 LocalContext context;
17647 v8::HandleScope scope(context->GetIsolate()); 17662 v8::HandleScope scope(context->GetIsolate());
17648 17663
17649 const char *source = 17664 const char *source =
17650 "function outer() {\n" 17665 "function outer() {\n"
(...skipping 4994 matching lines...) Expand 10 before | Expand all | Expand 10 after
22645 Local<Script> script = v8::ScriptCompiler::Compile( 22660 Local<Script> script = v8::ScriptCompiler::Compile(
22646 isolate, &script_source); 22661 isolate, &script_source);
22647 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22662 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22648 CHECK(!script_name.IsEmpty()); 22663 CHECK(!script_name.IsEmpty());
22649 CHECK(script_name->IsString()); 22664 CHECK(script_name->IsString());
22650 String::Utf8Value utf8_name(script_name); 22665 String::Utf8Value utf8_name(script_name);
22651 CHECK_EQ(url, *utf8_name); 22666 CHECK_EQ(url, *utf8_name);
22652 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22667 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22653 CHECK_EQ(13, line_number); 22668 CHECK_EQ(13, line_number);
22654 } 22669 }
OLDNEW
« src/scanner.cc ('K') | « src/vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698