OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 v8::internal::V8::Initialize(NULL); | 1676 v8::internal::V8::Initialize(NULL); |
1677 Zone zone(CcTest::i_isolate()); | 1677 Zone zone(CcTest::i_isolate()); |
1678 ZoneList<CharacterRange>* list = | 1678 ZoneList<CharacterRange>* list = |
1679 new(&zone) ZoneList<CharacterRange>(4, &zone); | 1679 new(&zone) ZoneList<CharacterRange>(4, &zone); |
1680 CharacterSet set(list); | 1680 CharacterSet set(list); |
1681 | 1681 |
1682 list->Add(CharacterRange(10, 20), &zone); | 1682 list->Add(CharacterRange(10, 20), &zone); |
1683 list->Add(CharacterRange(30, 40), &zone); | 1683 list->Add(CharacterRange(30, 40), &zone); |
1684 list->Add(CharacterRange(50, 60), &zone); | 1684 list->Add(CharacterRange(50, 60), &zone); |
1685 set.Canonicalize(); | 1685 set.Canonicalize(); |
1686 ASSERT_EQ(3, list->length()); | 1686 DCHECK_EQ(3, list->length()); |
1687 ASSERT_EQ(10, list->at(0).from()); | 1687 DCHECK_EQ(10, list->at(0).from()); |
1688 ASSERT_EQ(20, list->at(0).to()); | 1688 DCHECK_EQ(20, list->at(0).to()); |
1689 ASSERT_EQ(30, list->at(1).from()); | 1689 DCHECK_EQ(30, list->at(1).from()); |
1690 ASSERT_EQ(40, list->at(1).to()); | 1690 DCHECK_EQ(40, list->at(1).to()); |
1691 ASSERT_EQ(50, list->at(2).from()); | 1691 DCHECK_EQ(50, list->at(2).from()); |
1692 ASSERT_EQ(60, list->at(2).to()); | 1692 DCHECK_EQ(60, list->at(2).to()); |
1693 | 1693 |
1694 list->Rewind(0); | 1694 list->Rewind(0); |
1695 list->Add(CharacterRange(10, 20), &zone); | 1695 list->Add(CharacterRange(10, 20), &zone); |
1696 list->Add(CharacterRange(50, 60), &zone); | 1696 list->Add(CharacterRange(50, 60), &zone); |
1697 list->Add(CharacterRange(30, 40), &zone); | 1697 list->Add(CharacterRange(30, 40), &zone); |
1698 set.Canonicalize(); | 1698 set.Canonicalize(); |
1699 ASSERT_EQ(3, list->length()); | 1699 DCHECK_EQ(3, list->length()); |
1700 ASSERT_EQ(10, list->at(0).from()); | 1700 DCHECK_EQ(10, list->at(0).from()); |
1701 ASSERT_EQ(20, list->at(0).to()); | 1701 DCHECK_EQ(20, list->at(0).to()); |
1702 ASSERT_EQ(30, list->at(1).from()); | 1702 DCHECK_EQ(30, list->at(1).from()); |
1703 ASSERT_EQ(40, list->at(1).to()); | 1703 DCHECK_EQ(40, list->at(1).to()); |
1704 ASSERT_EQ(50, list->at(2).from()); | 1704 DCHECK_EQ(50, list->at(2).from()); |
1705 ASSERT_EQ(60, list->at(2).to()); | 1705 DCHECK_EQ(60, list->at(2).to()); |
1706 | 1706 |
1707 list->Rewind(0); | 1707 list->Rewind(0); |
1708 list->Add(CharacterRange(30, 40), &zone); | 1708 list->Add(CharacterRange(30, 40), &zone); |
1709 list->Add(CharacterRange(10, 20), &zone); | 1709 list->Add(CharacterRange(10, 20), &zone); |
1710 list->Add(CharacterRange(25, 25), &zone); | 1710 list->Add(CharacterRange(25, 25), &zone); |
1711 list->Add(CharacterRange(100, 100), &zone); | 1711 list->Add(CharacterRange(100, 100), &zone); |
1712 list->Add(CharacterRange(1, 1), &zone); | 1712 list->Add(CharacterRange(1, 1), &zone); |
1713 set.Canonicalize(); | 1713 set.Canonicalize(); |
1714 ASSERT_EQ(5, list->length()); | 1714 DCHECK_EQ(5, list->length()); |
1715 ASSERT_EQ(1, list->at(0).from()); | 1715 DCHECK_EQ(1, list->at(0).from()); |
1716 ASSERT_EQ(1, list->at(0).to()); | 1716 DCHECK_EQ(1, list->at(0).to()); |
1717 ASSERT_EQ(10, list->at(1).from()); | 1717 DCHECK_EQ(10, list->at(1).from()); |
1718 ASSERT_EQ(20, list->at(1).to()); | 1718 DCHECK_EQ(20, list->at(1).to()); |
1719 ASSERT_EQ(25, list->at(2).from()); | 1719 DCHECK_EQ(25, list->at(2).from()); |
1720 ASSERT_EQ(25, list->at(2).to()); | 1720 DCHECK_EQ(25, list->at(2).to()); |
1721 ASSERT_EQ(30, list->at(3).from()); | 1721 DCHECK_EQ(30, list->at(3).from()); |
1722 ASSERT_EQ(40, list->at(3).to()); | 1722 DCHECK_EQ(40, list->at(3).to()); |
1723 ASSERT_EQ(100, list->at(4).from()); | 1723 DCHECK_EQ(100, list->at(4).from()); |
1724 ASSERT_EQ(100, list->at(4).to()); | 1724 DCHECK_EQ(100, list->at(4).to()); |
1725 | 1725 |
1726 list->Rewind(0); | 1726 list->Rewind(0); |
1727 list->Add(CharacterRange(10, 19), &zone); | 1727 list->Add(CharacterRange(10, 19), &zone); |
1728 list->Add(CharacterRange(21, 30), &zone); | 1728 list->Add(CharacterRange(21, 30), &zone); |
1729 list->Add(CharacterRange(20, 20), &zone); | 1729 list->Add(CharacterRange(20, 20), &zone); |
1730 set.Canonicalize(); | 1730 set.Canonicalize(); |
1731 ASSERT_EQ(1, list->length()); | 1731 DCHECK_EQ(1, list->length()); |
1732 ASSERT_EQ(10, list->at(0).from()); | 1732 DCHECK_EQ(10, list->at(0).from()); |
1733 ASSERT_EQ(30, list->at(0).to()); | 1733 DCHECK_EQ(30, list->at(0).to()); |
1734 } | 1734 } |
1735 | 1735 |
1736 | 1736 |
1737 TEST(CharacterRangeMerge) { | 1737 TEST(CharacterRangeMerge) { |
1738 v8::internal::V8::Initialize(NULL); | 1738 v8::internal::V8::Initialize(NULL); |
1739 Zone zone(CcTest::i_isolate()); | 1739 Zone zone(CcTest::i_isolate()); |
1740 ZoneList<CharacterRange> l1(4, &zone); | 1740 ZoneList<CharacterRange> l1(4, &zone); |
1741 ZoneList<CharacterRange> l2(4, &zone); | 1741 ZoneList<CharacterRange> l2(4, &zone); |
1742 // Create all combinations of intersections of ranges, both singletons and | 1742 // Create all combinations of intersections of ranges, both singletons and |
1743 // longer. | 1743 // longer. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y | 1806 // YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y |
1807 | 1807 |
1808 l1.Add(CharacterRange::Range(offset, offset + 21), &zone); | 1808 l1.Add(CharacterRange::Range(offset, offset + 21), &zone); |
1809 l1.Add(CharacterRange::Range(offset + 31, offset + 52), &zone); | 1809 l1.Add(CharacterRange::Range(offset + 31, offset + 52), &zone); |
1810 for (int i = 0; i < 6; i++) { | 1810 for (int i = 0; i < 6; i++) { |
1811 l2.Add(CharacterRange::Range(offset + 2, offset + 5), &zone); | 1811 l2.Add(CharacterRange::Range(offset + 2, offset + 5), &zone); |
1812 l2.Add(CharacterRange::Singleton(offset + 8), &zone); | 1812 l2.Add(CharacterRange::Singleton(offset + 8), &zone); |
1813 offset += 9; | 1813 offset += 9; |
1814 } | 1814 } |
1815 | 1815 |
1816 ASSERT(CharacterRange::IsCanonical(&l1)); | 1816 DCHECK(CharacterRange::IsCanonical(&l1)); |
1817 ASSERT(CharacterRange::IsCanonical(&l2)); | 1817 DCHECK(CharacterRange::IsCanonical(&l2)); |
1818 | 1818 |
1819 ZoneList<CharacterRange> first_only(4, &zone); | 1819 ZoneList<CharacterRange> first_only(4, &zone); |
1820 ZoneList<CharacterRange> second_only(4, &zone); | 1820 ZoneList<CharacterRange> second_only(4, &zone); |
1821 ZoneList<CharacterRange> both(4, &zone); | 1821 ZoneList<CharacterRange> both(4, &zone); |
1822 } | 1822 } |
1823 | 1823 |
1824 | 1824 |
1825 TEST(Graph) { | 1825 TEST(Graph) { |
1826 V8::Initialize(NULL); | 1826 V8::Initialize(NULL); |
1827 Execute("\\b\\w+\\b", false, true, true); | 1827 Execute("\\b\\w+\\b", false, true, true); |
1828 } | 1828 } |
OLD | NEW |