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-regexp.cc

Issue 11442: Fix test crashes I just introduced. (Closed)
Patch Set: Created 12 years, 1 month 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
« no previous file with comments | « src/unicode.cc ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 DispatchTable table; 708 DispatchTable table;
709 DispatchTableConstructor cons(&table); 709 DispatchTableConstructor cons(&table);
710 cons.set_choice_index(0); 710 cons.set_choice_index(0);
711 cons.AddInverse(ranges); 711 cons.AddInverse(ranges);
712 CHECK(!table.Get(0xFFFE)->Get(0)); 712 CHECK(!table.Get(0xFFFE)->Get(0));
713 CHECK(table.Get(0xFFFF)->Get(0)); 713 CHECK(table.Get(0xFFFF)->Get(0));
714 } 714 }
715 715
716 716
717 static uc32 canonicalize(uc32 c) { 717 static uc32 canonicalize(uc32 c) {
718 unibrow::uchar canon[unibrow::kMaxMappingSize]; 718 unibrow::uchar canon[unibrow::Ecma262Canonicalize::kMaxWidth];
719 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL); 719 int count = unibrow::Ecma262Canonicalize::Convert(c, '\0', canon, NULL);
720 if (count == 0) { 720 if (count == 0) {
721 return c; 721 return c;
722 } else { 722 } else {
723 CHECK_EQ(1, count); 723 CHECK_EQ(1, count);
724 return canon[0]; 724 return canon[0];
725 } 725 }
726 } 726 }
727 727
728 728
729 TEST(LatinCanonicalize) { 729 TEST(LatinCanonicalize) {
730 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize; 730 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize;
731 for (char lower = 'a'; lower <= 'z'; lower++) { 731 for (char lower = 'a'; lower <= 'z'; lower++) {
732 char upper = lower + ('A' - 'a'); 732 char upper = lower + ('A' - 'a');
733 CHECK_EQ(canonicalize(lower), canonicalize(upper)); 733 CHECK_EQ(canonicalize(lower), canonicalize(upper));
734 unibrow::uchar uncanon[unibrow::kMaxMappingSize]; 734 unibrow::uchar uncanon[unibrow::Ecma262UnCanonicalize::kMaxWidth];
735 int length = un_canonicalize.get(lower, '\0', uncanon); 735 int length = un_canonicalize.get(lower, '\0', uncanon);
736 CHECK_EQ(2, length); 736 CHECK_EQ(2, length);
737 CHECK_EQ(upper, uncanon[0]); 737 CHECK_EQ(upper, uncanon[0]);
738 CHECK_EQ(lower, uncanon[1]); 738 CHECK_EQ(lower, uncanon[1]);
739 } 739 }
740 for (uc32 c = 128; c < (1 << 21); c++) { 740 for (uc32 c = 128; c < (1 << 21); c++) {
741 // These exceptions are caused by a known bug in the implementation. 741 // These exceptions are caused by a known bug in the implementation.
742 if (c != 0x026B && c != 0x027D) 742 if (c != 0x026B && c != 0x027D)
743 CHECK_GE(canonicalize(c), 128); 743 CHECK_GE(canonicalize(c), 128);
744 } 744 }
745 unibrow::Mapping<unibrow::ToUppercase> to_upper; 745 unibrow::Mapping<unibrow::ToUppercase> to_upper;
746 for (uc32 c = 0; c < (1 << 21); c++) { 746 for (uc32 c = 0; c < (1 << 21); c++) {
747 if (c == 0x026B || c == 0x027D) continue; 747 if (c == 0x026B || c == 0x027D) continue;
748 unibrow::uchar upper[unibrow::kMaxMappingSize]; 748 unibrow::uchar upper[unibrow::ToUppercase::kMaxWidth];
749 int length = to_upper.get(c, '\0', upper); 749 int length = to_upper.get(c, '\0', upper);
750 if (length == 0) { 750 if (length == 0) {
751 length = 1; 751 length = 1;
752 upper[0] = c; 752 upper[0] = c;
753 } 753 }
754 uc32 u = upper[0]; 754 uc32 u = upper[0];
755 if (length > 1 || (c >= 128 && u < 128)) 755 if (length > 1 || (c >= 128 && u < 128))
756 u = c; 756 u = c;
757 if (u != canonicalize(c)) 757 if (u != canonicalize(c))
758 printf("%x\n", c); 758 printf("%x\n", c);
759 CHECK_EQ(u, canonicalize(c)); 759 CHECK_EQ(u, canonicalize(c));
760 } 760 }
761 } 761 }
762 762
763 763
764 TEST(SimplePropagation) { 764 TEST(SimplePropagation) {
765 v8::HandleScope scope; 765 v8::HandleScope scope;
766 ZoneScope zone_scope(DELETE_ON_EXIT); 766 ZoneScope zone_scope(DELETE_ON_EXIT);
767 RegExpNode* node = Compile("(a|^b|c)"); 767 RegExpNode* node = Compile("(a|^b|c)");
768 CHECK(node->info()->determine_start); 768 CHECK(node->info()->determine_start);
769 } 769 }
770 770
771 771
772 TEST(Graph) { 772 TEST(Graph) {
773 Execute("(a|^b|c)", "", true); 773 Execute("(a|^b|c)", "", true);
774 } 774 }
OLDNEW
« no previous file with comments | « src/unicode.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698