OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. All rights reserved. | 1 // Copyright (c) 2014, the Dart project authors. All rights reserved. |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 assertThrows(() => new RegExp('(?=*)')); | 584 assertThrows(() => new RegExp('(?=*)')); |
585 assertThrows(() => new RegExp('(?!*)')); | 585 assertThrows(() => new RegExp('(?!*)')); |
586 | 586 |
587 // Test trimmed regular expression for RegExp.test(). | 587 // Test trimmed regular expression for RegExp.test(). |
588 assertTrue("abc".contains(new RegExp(r".*abc"))); | 588 assertTrue("abc".contains(new RegExp(r".*abc"))); |
589 assertFalse("q".contains(new RegExp(r".*\d+"))); | 589 assertFalse("q".contains(new RegExp(r".*\d+"))); |
590 | 590 |
591 // Tests skipped from V8: | 591 // Tests skipped from V8: |
592 // Test that RegExp.prototype.toString() throws TypeError for | 592 // Test that RegExp.prototype.toString() throws TypeError for |
593 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). | 593 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). |
| 594 |
| 595 testSticky(); |
594 } | 596 } |
| 597 |
| 598 testSticky() { |
| 599 var re = new RegExp(r"foo.bar"); |
| 600 Expect.isNotNull(re.matchAsPrefix("foo_bar", 0)); |
| 601 Expect.isNull(re.matchAsPrefix("..foo_bar", 0)); |
| 602 Expect.isNotNull(re.matchAsPrefix("..foo_bar", 2)); |
| 603 |
| 604 re = new RegExp(r"^foo"); |
| 605 Expect.isNotNull(re.matchAsPrefix("foobar", 0)); |
| 606 Expect.isNull(re.matchAsPrefix("..foo", 0)); |
| 607 Expect.isNull(re.matchAsPrefix("..foo", 2)); |
| 608 |
| 609 re = new RegExp(r"^foo", multiLine: true); |
| 610 Expect.isNotNull(re.matchAsPrefix("foobar", 0)); |
| 611 Expect.isNull(re.matchAsPrefix("..\nfoo", 0)); |
| 612 Expect.isNotNull(re.matchAsPrefix("..\nfoo", 3)); |
| 613 Expect.isNull(re.matchAsPrefix("..\nfoofoo", 6)); |
| 614 |
| 615 re = new RegExp(r"bar$"); |
| 616 Expect.isNull(re.matchAsPrefix("foobar", 0)); |
| 617 Expect.isNotNull(re.matchAsPrefix("foobar", 3)); |
| 618 } |
OLD | NEW |