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

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

Issue 3330001: Fix parsing of /**/--> on first line of input. (Closed)
Patch Set: Added test-case. Created 10 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
« no previous file with comments | « src/scanner.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "token.h" 32 #include "token.h"
33 #include "scanner.h" 33 #include "scanner.h"
34 #include "utils.h" 34 #include "utils.h"
35 #include "execution.h"
35 36
36 #include "cctest.h" 37 #include "cctest.h"
37 38
38 namespace i = ::v8::internal; 39 namespace i = ::v8::internal;
39 40
40 TEST(KeywordMatcher) { 41 TEST(KeywordMatcher) {
41 struct KeywordToken { 42 struct KeywordToken {
42 const char* keyword; 43 const char* keyword;
43 i::Token::Value token; 44 i::Token::Value token;
44 }; 45 };
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // If we mark it as failure, continuing won't help. 121 // If we mark it as failure, continuing won't help.
121 i::KeywordMatcher full_stop; 122 i::KeywordMatcher full_stop;
122 full_stop.AddChar('i'); 123 full_stop.AddChar('i');
123 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 124 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
124 full_stop.Fail(); 125 full_stop.Fail();
125 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 126 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
126 full_stop.AddChar('f'); 127 full_stop.AddChar('f');
127 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 128 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
128 } 129 }
129 130
131
132 TEST(ScanHTMLEndComments) {
133 // Regression test. See:
134 // http://code.google.com/p/chromium/issues/detail?id=53548
135 // Tests that --> is correctly interpreted as comment-to-end-of-line if there
136 // is only whitespace before it on the line, even after a multiline-comment
137 // comment. This was not the case if it occurred before the first real token
138 // in the input.
139 const char* tests[] = {
140 // Before first real token.
141 "--> is eol-comment\nvar y = 37;\n",
142 "\n --> is eol-comment\nvar y = 37;\n",
143 "/* precomment */ --> is eol-comment\nvar y = 37;\n",
144 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
145 // After first real token.
146 "var x = 42;\n--> is eol-comment\nvar y = 37;\n",
147 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
148 NULL
149 };
150
151 // Parser needs a stack limit.
152 int marker;
153 i::StackGuard::SetStackLimit(
154 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
155
156 for (int i = 0; tests[i]; i++) {
157 v8::ScriptData* data =
158 v8::ScriptData::PreCompile(tests[i], strlen(tests[i]));
159 CHECK(data != NULL && !data->HasError());
160 delete data;
161 }
162 }
OLDNEW
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698