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

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

Issue 8306024: Make native syntax an early error in the preparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified enums Created 9 years, 2 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/scanner.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 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); 253 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit();
254 for (int i = 0; programs[i]; i++) { 254 for (int i = 0; programs[i]; i++) {
255 const char* program = programs[i]; 255 const char* program = programs[i];
256 i::Utf8ToUC16CharacterStream stream( 256 i::Utf8ToUC16CharacterStream stream(
257 reinterpret_cast<const i::byte*>(program), 257 reinterpret_cast<const i::byte*>(program),
258 static_cast<unsigned>(strlen(program))); 258 static_cast<unsigned>(strlen(program)));
259 i::CompleteParserRecorder log; 259 i::CompleteParserRecorder log;
260 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); 260 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache());
261 scanner.Initialize(&stream); 261 scanner.Initialize(&stream);
262 262
263 int flags = i::kAllowLazy | i::kAllowNativesSyntax;
263 v8::preparser::PreParser::PreParseResult result = 264 v8::preparser::PreParser::PreParseResult result =
264 v8::preparser::PreParser::PreParseProgram(&scanner, 265 v8::preparser::PreParser::PreParseProgram(&scanner,
265 &log, 266 &log,
266 true, 267 flags,
267 stack_limit); 268 stack_limit);
268 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); 269 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result);
269 i::ScriptDataImpl data(log.ExtractData()); 270 i::ScriptDataImpl data(log.ExtractData());
270 CHECK(!data.has_error()); 271 CHECK(!data.has_error());
271 } 272 }
272 } 273 }
273 274
274 275
276 TEST(StandAlonePreParserNoNatives) {
277 v8::V8::Initialize();
278
279 int marker;
280 i::Isolate::Current()->stack_guard()->SetStackLimit(
281 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
282
283 const char* programs[] = {
284 "%ArgleBargle(glop);",
285 "var x = %_IsSmi(42);",
286 NULL
287 };
288
289 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit();
290 for (int i = 0; programs[i]; i++) {
291 const char* program = programs[i];
292 i::Utf8ToUC16CharacterStream stream(
293 reinterpret_cast<const i::byte*>(program),
294 static_cast<unsigned>(strlen(program)));
295 i::CompleteParserRecorder log;
296 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache());
297 scanner.Initialize(&stream);
298
299 // Flags don't allow natives syntax.
300 v8::preparser::PreParser::PreParseResult result =
301 v8::preparser::PreParser::PreParseProgram(&scanner,
302 &log,
303 i::kAllowLazy,
304 stack_limit);
305 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result);
306 i::ScriptDataImpl data(log.ExtractData());
307 // Data contains syntax error.
308 CHECK(data.has_error());
309 }
310 }
311
312
275 TEST(RegressChromium62639) { 313 TEST(RegressChromium62639) {
276 v8::V8::Initialize(); 314 v8::V8::Initialize();
277 315
278 int marker; 316 int marker;
279 i::Isolate::Current()->stack_guard()->SetStackLimit( 317 i::Isolate::Current()->stack_guard()->SetStackLimit(
280 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 318 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
281 319
282 const char* program = "var x = 'something';\n" 320 const char* program = "var x = 'something';\n"
283 "escape: function() {}"; 321 "escape: function() {}";
284 // Fails parsing expecting an identifier after "function". 322 // Fails parsing expecting an identifier after "function".
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); 737 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]");
700 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); 738 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]");
701 // Escaped ']'s wont end the character class. 739 // Escaped ']'s wont end the character class.
702 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); 740 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]");
703 // Escaped slashes are not terminating. 741 // Escaped slashes are not terminating.
704 TestScanRegExp("/\\//flipperwald", "\\/"); 742 TestScanRegExp("/\\//flipperwald", "\\/");
705 // Starting with '=' works too. 743 // Starting with '=' works too.
706 TestScanRegExp("/=/", "="); 744 TestScanRegExp("/=/", "=");
707 TestScanRegExp("/=?/", "=?"); 745 TestScanRegExp("/=?/", "=?");
708 } 746 }
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698