OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 CHECK_EQ(in_overlay, InClass(i, included)); | 1543 CHECK_EQ(in_overlay, InClass(i, included)); |
1544 CHECK_EQ(!in_overlay, InClass(i, excluded)); | 1544 CHECK_EQ(!in_overlay, InClass(i, excluded)); |
1545 } else { | 1545 } else { |
1546 CHECK(!InClass(i, included)); | 1546 CHECK(!InClass(i, included)); |
1547 CHECK(!InClass(i, excluded)); | 1547 CHECK(!InClass(i, excluded)); |
1548 } | 1548 } |
1549 } | 1549 } |
1550 } | 1550 } |
1551 | 1551 |
1552 | 1552 |
| 1553 TEST(CanonicalizeCharacterSets) { |
| 1554 ZoneScope scope(DELETE_ON_EXIT); |
| 1555 ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4); |
| 1556 CharacterSet set(list); |
| 1557 |
| 1558 list->Add(CharacterRange(10, 20)); |
| 1559 list->Add(CharacterRange(30, 40)); |
| 1560 list->Add(CharacterRange(50, 60)); |
| 1561 set.Canonicalize(); |
| 1562 ASSERT_EQ(3, list->length()); |
| 1563 ASSERT_EQ(10, list->at(0).from()); |
| 1564 ASSERT_EQ(20, list->at(0).to()); |
| 1565 ASSERT_EQ(30, list->at(1).from()); |
| 1566 ASSERT_EQ(40, list->at(1).to()); |
| 1567 ASSERT_EQ(50, list->at(2).from()); |
| 1568 ASSERT_EQ(60, list->at(2).to()); |
| 1569 |
| 1570 list->Rewind(0); |
| 1571 list->Add(CharacterRange(10, 20)); |
| 1572 list->Add(CharacterRange(50, 60)); |
| 1573 list->Add(CharacterRange(30, 40)); |
| 1574 set.Canonicalize(); |
| 1575 ASSERT_EQ(3, list->length()); |
| 1576 ASSERT_EQ(10, list->at(0).from()); |
| 1577 ASSERT_EQ(20, list->at(0).to()); |
| 1578 ASSERT_EQ(30, list->at(1).from()); |
| 1579 ASSERT_EQ(40, list->at(1).to()); |
| 1580 ASSERT_EQ(50, list->at(2).from()); |
| 1581 ASSERT_EQ(60, list->at(2).to()); |
| 1582 |
| 1583 list->Rewind(0); |
| 1584 list->Add(CharacterRange(30, 40)); |
| 1585 list->Add(CharacterRange(10, 20)); |
| 1586 list->Add(CharacterRange(25, 25)); |
| 1587 list->Add(CharacterRange(100, 100)); |
| 1588 list->Add(CharacterRange(1, 1)); |
| 1589 set.Canonicalize(); |
| 1590 ASSERT_EQ(5, list->length()); |
| 1591 ASSERT_EQ(1, list->at(0).from()); |
| 1592 ASSERT_EQ(1, list->at(0).to()); |
| 1593 ASSERT_EQ(10, list->at(1).from()); |
| 1594 ASSERT_EQ(20, list->at(1).to()); |
| 1595 ASSERT_EQ(25, list->at(2).from()); |
| 1596 ASSERT_EQ(25, list->at(2).to()); |
| 1597 ASSERT_EQ(30, list->at(3).from()); |
| 1598 ASSERT_EQ(40, list->at(3).to()); |
| 1599 ASSERT_EQ(100, list->at(4).from()); |
| 1600 ASSERT_EQ(100, list->at(4).to()); |
| 1601 |
| 1602 list->Rewind(0); |
| 1603 list->Add(CharacterRange(10, 19)); |
| 1604 list->Add(CharacterRange(21, 30)); |
| 1605 list->Add(CharacterRange(20, 20)); |
| 1606 set.Canonicalize(); |
| 1607 ASSERT_EQ(1, list->length()); |
| 1608 ASSERT_EQ(10, list->at(0).from()); |
| 1609 ASSERT_EQ(30, list->at(0).to()); |
| 1610 } |
| 1611 |
| 1612 |
| 1613 |
1553 TEST(Graph) { | 1614 TEST(Graph) { |
1554 V8::Initialize(NULL); | 1615 V8::Initialize(NULL); |
1555 Execute("(?:(?:x(.))?\1)+$", false, true, true); | 1616 Execute("\\b\\w+\\b", false, true, true); |
1556 } | 1617 } |
OLD | NEW |