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

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

Issue 12638: Fixed uncanonicalization inconsistency. (Closed)
Patch Set: Created 12 years 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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 // Check that we arrive at the same results when skipping over 1079 // Check that we arrive at the same results when skipping over
1080 // canonicalization ranges. 1080 // canonicalization ranges.
1081 int next_block = 0; 1081 int next_block = 0;
1082 while (next_block < CharacterRange::kRangeCanonicalizeMax) { 1082 while (next_block < CharacterRange::kRangeCanonicalizeMax) {
1083 uc32 start = CanonRange(next_block); 1083 uc32 start = CanonRange(next_block);
1084 CHECK_NE((start & CharacterRange::kStartMarker), 0); 1084 CHECK_NE((start & CharacterRange::kStartMarker), 0);
1085 unsigned dist = start & CharacterRange::kPayloadMask; 1085 unsigned dist = start & CharacterRange::kPayloadMask;
1086 unibrow::uchar first[unibrow::Ecma262UnCanonicalize::kMaxWidth]; 1086 unibrow::uchar first[unibrow::Ecma262UnCanonicalize::kMaxWidth];
1087 int first_length = un_canonicalize.get(next_block, '\0', first); 1087 int first_length = un_canonicalize.get(next_block, '\0', first);
1088 for (unsigned i = 1; i < dist; i++) { 1088 for (unsigned i = 1; i < dist; i++) {
1089 CHECK_EQ(i, CanonRange(i)); 1089 uc32 i_range = CanonRange(next_block + i);
1090 if (next_block + i == 880)
Erik Corry 2008/11/25 18:24:51 I don't understand this change.
Christian Plesner Hansen 2008/11/26 06:03:45 That was a mistake.
1091 CanonRange(next_block + i);
1092 CHECK_EQ(i, i_range);
1090 unibrow::uchar succ[unibrow::Ecma262UnCanonicalize::kMaxWidth]; 1093 unibrow::uchar succ[unibrow::Ecma262UnCanonicalize::kMaxWidth];
1091 int succ_length = un_canonicalize.get(next_block + i, '\0', succ); 1094 int succ_length = un_canonicalize.get(next_block + i, '\0', succ);
1092 CHECK_EQ(first_length, succ_length); 1095 CHECK_EQ(first_length, succ_length);
1093 for (int j = 0; j < succ_length; j++) { 1096 for (int j = 0; j < succ_length; j++) {
1094 int calc = first[j] + i; 1097 int calc = first[j] + i;
1095 int found = succ[j]; 1098 int found = succ[j];
1096 CHECK_EQ(calc, found); 1099 CHECK_EQ(calc, found);
1097 } 1100 }
1098 } 1101 }
1099 next_block = next_block + dist; 1102 next_block = next_block + dist;
1100 } 1103 }
1101 } 1104 }
1102 1105
1103 1106
1107 TEST(UncanonicalizeEquivalence) {
1108 unibrow::Mapping<unibrow::Ecma262UnCanonicalize> un_canonicalize;
1109 unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth];
1110 for (int i = 0; i < (1 << 16); i++) {
1111 int length = un_canonicalize.get(i, '\0', chars);
1112 for (int j = 0; j < length; j++) {
1113 unibrow::uchar chars2[unibrow::Ecma262UnCanonicalize::kMaxWidth];
1114 int length2 = un_canonicalize.get(chars[j], '\0', chars2);
1115 CHECK_EQ(length, length2);
1116 for (int k = 0; k < length; k++)
1117 CHECK_EQ(static_cast<int>(chars[k]), static_cast<int>(chars2[k]));
1118 }
1119 }
1120 }
1121
1122
1104 static void TestRangeCaseIndependence(CharacterRange input, 1123 static void TestRangeCaseIndependence(CharacterRange input,
1105 Vector<CharacterRange> expected) { 1124 Vector<CharacterRange> expected) {
1106 ZoneScope zone_scope(DELETE_ON_EXIT); 1125 ZoneScope zone_scope(DELETE_ON_EXIT);
1107 int count = expected.length(); 1126 int count = expected.length();
1108 ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(count); 1127 ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(count);
1109 input.AddCaseEquivalents(list); 1128 input.AddCaseEquivalents(list);
1110 CHECK_EQ(count, list->length()); 1129 CHECK_EQ(count, list->length());
1111 for (int i = 0; i < list->length(); i++) { 1130 for (int i = 0; i < list->length(); i++) {
1112 CHECK_EQ(expected[i].from(), list->at(i).from()); 1131 CHECK_EQ(expected[i].from(), list->at(i).from());
1113 CHECK_EQ(expected[i].to(), list->at(i).to()); 1132 CHECK_EQ(expected[i].to(), list->at(i).to());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 // whole block at a time. 1168 // whole block at a time.
1150 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'), 1169 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'),
1151 CharacterRange('a', 'z')); 1170 CharacterRange('a', 'z'));
1152 } 1171 }
1153 1172
1154 1173
1155 TEST(Graph) { 1174 TEST(Graph) {
1156 V8::Initialize(NULL); 1175 V8::Initialize(NULL);
1157 Execute("(x)?\\1y", "", true); 1176 Execute("(x)?\\1y", "", true);
1158 } 1177 }
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