OLD | NEW |
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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 "var bar = function () { /* second */ }"; | 314 "var bar = function () { /* second */ }"; |
315 | 315 |
316 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), | 316 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), |
317 static_cast<unsigned>(strlen(program))); | 317 static_cast<unsigned>(strlen(program))); |
318 i::ScriptDataImpl* data = | 318 i::ScriptDataImpl* data = |
319 i::ParserApi::PartialPreParse(&stream, NULL); | 319 i::ParserApi::PartialPreParse(&stream, NULL); |
320 CHECK(!data->HasError()); | 320 CHECK(!data->HasError()); |
321 | 321 |
322 data->Initialize(); | 322 data->Initialize(); |
323 | 323 |
324 int first_function = strstr(program, "function") - program; | 324 intptr_t first_function = strstr(program, "function") - program; |
325 int first_lbrace = first_function + strlen("function () "); | 325 intptr_t first_lbrace = first_function + strlen("function () "); |
326 CHECK_EQ('{', program[first_lbrace]); | 326 CHECK_EQ('{', program[first_lbrace]); |
327 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); | 327 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); |
328 CHECK(!entry1.is_valid()); | 328 CHECK(!entry1.is_valid()); |
329 | 329 |
330 int second_function = strstr(program + first_lbrace, "function") - program; | 330 intptr_t second_function = |
331 int second_lbrace = second_function + strlen("function () "); | 331 strstr(program + first_lbrace, "function") - program; |
| 332 intptr_t second_lbrace = second_function + strlen("function () "); |
332 CHECK_EQ('{', program[second_lbrace]); | 333 CHECK_EQ('{', program[second_lbrace]); |
333 i::FunctionEntry entry2 = data->GetFunctionEntry(second_lbrace); | 334 i::FunctionEntry entry2 = data->GetFunctionEntry(second_lbrace); |
334 CHECK(entry2.is_valid()); | 335 CHECK(entry2.is_valid()); |
335 CHECK_EQ('}', program[entry2.end_pos() - 1]); | 336 CHECK_EQ('}', program[entry2.end_pos() - 1]); |
336 delete data; | 337 delete data; |
337 } | 338 } |
338 | 339 |
339 | 340 |
340 TEST(PreParseOverflow) { | 341 TEST(PreParseOverflow) { |
341 int marker; | 342 int marker; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); | 694 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); |
694 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); | 695 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); |
695 // Escaped ']'s wont end the character class. | 696 // Escaped ']'s wont end the character class. |
696 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); | 697 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); |
697 // Escaped slashes are not terminating. | 698 // Escaped slashes are not terminating. |
698 TestScanRegExp("/\\//flipperwald", "\\/"); | 699 TestScanRegExp("/\\//flipperwald", "\\/"); |
699 // Starting with '=' works too. | 700 // Starting with '=' works too. |
700 TestScanRegExp("/=/", "="); | 701 TestScanRegExp("/=/", "="); |
701 TestScanRegExp("/=?/", "=?"); | 702 TestScanRegExp("/=?/", "=?"); |
702 } | 703 } |
OLD | NEW |