| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 assertEquals(false, desc.value); | 582 assertEquals(false, desc.value); |
| 583 assertEquals(false, desc.configurable); | 583 assertEquals(false, desc.configurable); |
| 584 assertEquals(false, desc.enumerable); | 584 assertEquals(false, desc.enumerable); |
| 585 assertEquals(false, desc.writable); | 585 assertEquals(false, desc.writable); |
| 586 | 586 |
| 587 desc = Object.getOwnPropertyDescriptor(re, "lastIndex"); | 587 desc = Object.getOwnPropertyDescriptor(re, "lastIndex"); |
| 588 assertEquals(0, desc.value); | 588 assertEquals(0, desc.value); |
| 589 assertEquals(false, desc.configurable); | 589 assertEquals(false, desc.configurable); |
| 590 assertEquals(false, desc.enumerable); | 590 assertEquals(false, desc.enumerable); |
| 591 assertEquals(true, desc.writable); | 591 assertEquals(true, desc.writable); |
| 592 | |
| 593 | |
| 594 // Check that end-anchored regexps are optimized correctly. | |
| 595 var re = /(?:a|bc)g$/; | |
| 596 assertTrue(re.test("ag")); | |
| 597 assertTrue(re.test("bcg")); | |
| 598 assertTrue(re.test("abcg")); | |
| 599 assertTrue(re.test("zimbag")); | |
| 600 assertTrue(re.test("zimbcg")); | |
| 601 | |
| 602 assertFalse(re.test("g")); | |
| 603 assertFalse(re.test("")); | |
| 604 | |
| 605 // Global regexp (non-zero start). | |
| 606 var re = /(?:a|bc)g$/g; | |
| 607 assertTrue(re.test("ag")); | |
| 608 re.lastIndex = 1; // Near start of string. | |
| 609 assertTrue(re.test("zimbag")); | |
| 610 re.lastIndex = 5; // Near end of string. | |
| 611 assertFalse(re.test("zimbag")); | |
| 612 re.lastIndex = 4; | |
| 613 assertTrue(re.test("zimbag")); | |
| 614 | |
| 615 // Anchored at both ends. | |
| 616 var re = /^(?:a|bc)g$/g; | |
| 617 assertTrue(re.test("ag")); | |
| 618 re.lastIndex = 1; | |
| 619 assertFalse(re.test("ag")); | |
| 620 re.lastIndex = 1; | |
| 621 assertFalse(re.test("zag")); | |
| 622 | |
| 623 // Long max_length of RegExp. | |
| 624 var re = /VeryLongRegExp!{1,1000}$/; | |
| 625 assertTrue(re.test("BahoolaVeryLongRegExp!!!!!!")); | |
| 626 assertFalse(re.test("VeryLongRegExp")); | |
| 627 assertFalse(re.test("!")); | |
| 628 | |
| 629 // End anchor inside disjunction. | |
| 630 var re = /(?:a$|bc$)/; | |
| 631 assertTrue(re.test("a")); | |
| 632 assertTrue(re.test("bc")); | |
| 633 assertTrue(re.test("abc")); | |
| 634 assertTrue(re.test("zimzamzumba")); | |
| 635 assertTrue(re.test("zimzamzumbc")); | |
| 636 assertFalse(re.test("c")); | |
| 637 assertFalse(re.test("")); | |
| 638 | |
| 639 // Only partially anchored. | |
| 640 var re = /(?:a|bc$)/; | |
| 641 assertTrue(re.test("a")); | |
| 642 assertTrue(re.test("bc")); | |
| 643 assertEquals(["a"], re.exec("abc")); | |
| 644 assertEquals(4, re.exec("zimzamzumba").index); | |
| 645 assertEquals(["bc"], re.exec("zimzomzumbc")); | |
| 646 assertFalse(re.test("c")); | |
| 647 assertFalse(re.test("")); | |
| OLD | NEW |