Index: test/cctest/test-regexp.cc |
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc |
index 6aa0730c0d776f9321f58cfd2692bd8d3feeadc8..4e49839689ed4571e71f69ca6529f11e26077275 100644 |
--- a/test/cctest/test-regexp.cc |
+++ b/test/cctest/test-regexp.cc |
@@ -1550,7 +1550,68 @@ TEST(CharClassDifference) { |
} |
+TEST(CanonicalizeCharacterSets) { |
+ ZoneScope scope(DELETE_ON_EXIT); |
+ ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4); |
+ CharacterSet set(list); |
+ |
+ list->Add(CharacterRange(10, 20)); |
+ list->Add(CharacterRange(30, 40)); |
+ list->Add(CharacterRange(50, 60)); |
+ set.Canonicalize(); |
+ ASSERT_EQ(3, list->length()); |
+ ASSERT_EQ(10, list->at(0).from()); |
+ ASSERT_EQ(20, list->at(0).to()); |
+ ASSERT_EQ(30, list->at(1).from()); |
+ ASSERT_EQ(40, list->at(1).to()); |
+ ASSERT_EQ(50, list->at(2).from()); |
+ ASSERT_EQ(60, list->at(2).to()); |
+ |
+ list->Rewind(0); |
+ list->Add(CharacterRange(10, 20)); |
+ list->Add(CharacterRange(50, 60)); |
+ list->Add(CharacterRange(30, 40)); |
+ set.Canonicalize(); |
+ ASSERT_EQ(3, list->length()); |
+ ASSERT_EQ(10, list->at(0).from()); |
+ ASSERT_EQ(20, list->at(0).to()); |
+ ASSERT_EQ(30, list->at(1).from()); |
+ ASSERT_EQ(40, list->at(1).to()); |
+ ASSERT_EQ(50, list->at(2).from()); |
+ ASSERT_EQ(60, list->at(2).to()); |
+ |
+ list->Rewind(0); |
+ list->Add(CharacterRange(30, 40)); |
+ list->Add(CharacterRange(10, 20)); |
+ list->Add(CharacterRange(25, 25)); |
+ list->Add(CharacterRange(100, 100)); |
+ list->Add(CharacterRange(1, 1)); |
+ set.Canonicalize(); |
+ ASSERT_EQ(5, list->length()); |
+ ASSERT_EQ(1, list->at(0).from()); |
+ ASSERT_EQ(1, list->at(0).to()); |
+ ASSERT_EQ(10, list->at(1).from()); |
+ ASSERT_EQ(20, list->at(1).to()); |
+ ASSERT_EQ(25, list->at(2).from()); |
+ ASSERT_EQ(25, list->at(2).to()); |
+ ASSERT_EQ(30, list->at(3).from()); |
+ ASSERT_EQ(40, list->at(3).to()); |
+ ASSERT_EQ(100, list->at(4).from()); |
+ ASSERT_EQ(100, list->at(4).to()); |
+ |
+ list->Rewind(0); |
+ list->Add(CharacterRange(10, 19)); |
+ list->Add(CharacterRange(21, 30)); |
+ list->Add(CharacterRange(20, 20)); |
+ set.Canonicalize(); |
+ ASSERT_EQ(1, list->length()); |
+ ASSERT_EQ(10, list->at(0).from()); |
+ ASSERT_EQ(30, list->at(0).to()); |
+} |
+ |
+ |
+ |
TEST(Graph) { |
V8::Initialize(NULL); |
- Execute("(?:(?:x(.))?\1)+$", false, true, true); |
+ Execute("\\b\\w+\\b", false, true, true); |
} |