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

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

Issue 7215015: Version 3.4.5.1. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 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
« no previous file with comments | « src/version.cc ('k') | test/mjsunit/arguments.js » ('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 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 130 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
131 full_stop.AddChar('f'); 131 full_stop.AddChar('f');
132 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); 132 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token());
133 } 133 }
134 134
135 135
136 TEST(ScanHTMLEndComments) { 136 TEST(ScanHTMLEndComments) {
137 // Regression test. See: 137 // Regression test. See:
138 // http://code.google.com/p/chromium/issues/detail?id=53548 138 // http://code.google.com/p/chromium/issues/detail?id=53548
139 // Tests that --> is correctly interpreted as comment-to-end-of-line if there 139 // Tests that --> is correctly interpreted as comment-to-end-of-line if there
140 // is only whitespace before it on the line, even after a multiline-comment 140 // is only whitespace before it on the line (with comments considered as
141 // comment. This was not the case if it occurred before the first real token 141 // whitespace, even a multiline-comment containing a newline).
142 // This was not the case if it occurred before the first real token
142 // in the input. 143 // in the input.
143 const char* tests[] = { 144 const char* tests[] = {
144 // Before first real token. 145 // Before first real token.
145 "--> is eol-comment\nvar y = 37;\n", 146 "--> is eol-comment\nvar y = 37;\n",
146 "\n --> is eol-comment\nvar y = 37;\n", 147 "\n --> is eol-comment\nvar y = 37;\n",
147 "/* precomment */ --> is eol-comment\nvar y = 37;\n", 148 "/* precomment */ --> is eol-comment\nvar y = 37;\n",
148 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n", 149 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
149 // After first real token. 150 // After first real token.
150 "var x = 42;\n--> is eol-comment\nvar y = 37;\n", 151 "var x = 42;\n--> is eol-comment\nvar y = 37;\n",
151 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n", 152 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
152 NULL 153 NULL
153 }; 154 };
154 155
156 const char* fail_tests[] = {
157 "x --> is eol-comment\nvar y = 37;\n",
158 "\"\\n\" --> is eol-comment\nvar y = 37;\n",
159 "x/* precomment */ --> is eol-comment\nvar y = 37;\n",
160 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n",
161 "var x = 42; --> is eol-comment\nvar y = 37;\n",
162 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
163 NULL
164 };
165
155 // Parser/Scanner needs a stack limit. 166 // Parser/Scanner needs a stack limit.
156 int marker; 167 int marker;
157 i::Isolate::Current()->stack_guard()->SetStackLimit( 168 i::Isolate::Current()->stack_guard()->SetStackLimit(
158 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 169 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
159 170
160 for (int i = 0; tests[i]; i++) { 171 for (int i = 0; tests[i]; i++) {
161 v8::ScriptData* data = 172 v8::ScriptData* data =
162 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i])); 173 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i]));
163 CHECK(data != NULL && !data->HasError()); 174 CHECK(data != NULL && !data->HasError());
164 delete data; 175 delete data;
165 } 176 }
177
178 for (int i = 0; fail_tests[i]; i++) {
179 v8::ScriptData* data =
180 v8::ScriptData::PreCompile(fail_tests[i], i::StrLength(fail_tests[i]));
181 CHECK(data == NULL || data->HasError());
182 delete data;
183 }
166 } 184 }
167 185
168 186
169 class ScriptResource : public v8::String::ExternalAsciiStringResource { 187 class ScriptResource : public v8::String::ExternalAsciiStringResource {
170 public: 188 public:
171 ScriptResource(const char* data, size_t length) 189 ScriptResource(const char* data, size_t length)
172 : data_(data), length_(length) { } 190 : data_(data), length_(length) { }
173 191
174 const char* data() const { return data_; } 192 const char* data() const { return data_; }
175 size_t length() const { return length_; } 193 size_t length() const { return length_; }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); 715 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]");
698 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); 716 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]");
699 // Escaped ']'s wont end the character class. 717 // Escaped ']'s wont end the character class.
700 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); 718 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]");
701 // Escaped slashes are not terminating. 719 // Escaped slashes are not terminating.
702 TestScanRegExp("/\\//flipperwald", "\\/"); 720 TestScanRegExp("/\\//flipperwald", "\\/");
703 // Starting with '=' works too. 721 // Starting with '=' works too.
704 TestScanRegExp("/=/", "="); 722 TestScanRegExp("/=/", "=");
705 TestScanRegExp("/=?/", "=?"); 723 TestScanRegExp("/=?/", "=?");
706 } 724 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | test/mjsunit/arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698