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