| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 i::UnicodeCache unicode_cache; | 57 i::UnicodeCache unicode_cache; |
| 58 i::byte buffer[32]; | 58 i::byte buffer[32]; |
| 59 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { | 59 for (int i = 0; (key_token = keywords[i]).keyword != NULL; i++) { |
| 60 const i::byte* keyword = | 60 const i::byte* keyword = |
| 61 reinterpret_cast<const i::byte*>(key_token.keyword); | 61 reinterpret_cast<const i::byte*>(key_token.keyword); |
| 62 int length = i::StrLength(key_token.keyword); | 62 int length = i::StrLength(key_token.keyword); |
| 63 CHECK(static_cast<int>(sizeof(buffer)) >= length); | 63 CHECK(static_cast<int>(sizeof(buffer)) >= length); |
| 64 { | 64 { |
| 65 i::Utf8ToUC16CharacterStream stream(keyword, length); | 65 i::Utf8ToUC16CharacterStream stream(keyword, length); |
| 66 i::JavaScriptScanner scanner(&unicode_cache); | 66 i::JavaScriptScanner scanner(&unicode_cache); |
| 67 scanner.Initialize(&stream); | |
| 68 // The scanner should parse 'let' as Token::LET for this test. | 67 // The scanner should parse 'let' as Token::LET for this test. |
| 69 scanner.SetHarmonyBlockScoping(true); | 68 scanner.SetHarmonyBlockScoping(true); |
| 69 scanner.Initialize(&stream); |
| 70 CHECK_EQ(key_token.token, scanner.Next()); | 70 CHECK_EQ(key_token.token, scanner.Next()); |
| 71 CHECK_EQ(i::Token::EOS, scanner.Next()); | 71 CHECK_EQ(i::Token::EOS, scanner.Next()); |
| 72 } | 72 } |
| 73 // Removing characters will make keyword matching fail. | 73 // Removing characters will make keyword matching fail. |
| 74 { | 74 { |
| 75 i::Utf8ToUC16CharacterStream stream(keyword, length - 1); | 75 i::Utf8ToUC16CharacterStream stream(keyword, length - 1); |
| 76 i::JavaScriptScanner scanner(&unicode_cache); | 76 i::JavaScriptScanner scanner(&unicode_cache); |
| 77 scanner.Initialize(&stream); | 77 scanner.Initialize(&stream); |
| 78 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); | 78 CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); |
| 79 CHECK_EQ(i::Token::EOS, scanner.Next()); | 79 CHECK_EQ(i::Token::EOS, scanner.Next()); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); | 699 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); |
| 700 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); | 700 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); |
| 701 // Escaped ']'s wont end the character class. | 701 // Escaped ']'s wont end the character class. |
| 702 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); | 702 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); |
| 703 // Escaped slashes are not terminating. | 703 // Escaped slashes are not terminating. |
| 704 TestScanRegExp("/\\//flipperwald", "\\/"); | 704 TestScanRegExp("/\\//flipperwald", "\\/"); |
| 705 // Starting with '=' works too. | 705 // Starting with '=' works too. |
| 706 TestScanRegExp("/=/", "="); | 706 TestScanRegExp("/=/", "="); |
| 707 TestScanRegExp("/=?/", "=?"); | 707 TestScanRegExp("/=?/", "=?"); |
| 708 } | 708 } |
| OLD | NEW |