| 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 return string; | 557 return string; |
| 558 }, | 558 }, |
| 559 length: 0 | 559 length: 0 |
| 560 }; | 560 }; |
| 561 | 561 |
| 562 var re = /str/; | 562 var re = /str/; |
| 563 log = []; | 563 log = []; |
| 564 re.lastIndex = fakeLastIndex; | 564 re.lastIndex = fakeLastIndex; |
| 565 var result = re.exec(fakeString); | 565 var result = re.exec(fakeString); |
| 566 assertEquals(["str"], result); | 566 assertEquals(["str"], result); |
| 567 assertEquals(["ts", "li"], log); | 567 assertEquals(["ts"], log); |
| 568 | 568 |
| 569 // Again, to check if caching interferes. | 569 // Again, to check if caching interferes. |
| 570 log = []; | 570 log = []; |
| 571 re.lastIndex = fakeLastIndex; | 571 re.lastIndex = fakeLastIndex; |
| 572 result = re.exec(fakeString); | 572 result = re.exec(fakeString); |
| 573 assertEquals(["str"], result); | 573 assertEquals(["str"], result); |
| 574 assertEquals(["ts", "li"], log); | 574 assertEquals(["ts"], log); |
| 575 | 575 |
| 576 // And one more time, just to be certain. | 576 // And one more time, just to be certain. |
| 577 log = []; | 577 log = []; |
| 578 re.lastIndex = fakeLastIndex; | 578 re.lastIndex = fakeLastIndex; |
| 579 result = re.exec(fakeString); | 579 result = re.exec(fakeString); |
| 580 assertEquals(["str"], result); | 580 assertEquals(["str"], result); |
| 581 assertEquals(["ts", "li"], log); | 581 assertEquals(["ts"], log); |
| 582 | 582 |
| 583 // Now with a global regexp, where lastIndex is actually used. | 583 // Now with a global regexp, where lastIndex is actually used. |
| 584 re = /str/g; | 584 re = /str/g; |
| 585 log = []; | 585 log = []; |
| 586 re.lastIndex = fakeLastIndex; | 586 re.lastIndex = fakeLastIndex; |
| 587 var result = re.exec(fakeString); | 587 var result = re.exec(fakeString); |
| 588 assertEquals(["str"], result); | 588 assertEquals(["str"], result); |
| 589 assertEquals(["ts", "li"], log); | 589 assertEquals(["ts", "li"], log); |
| 590 | 590 |
| 591 // Again, to check if caching interferes. | 591 // Again, to check if caching interferes. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 assertThrows("RegExp.prototype.toString.call('')", TypeError); | 719 assertThrows("RegExp.prototype.toString.call('')", TypeError); |
| 720 assertThrows("RegExp.prototype.toString.call(false)", TypeError); | 720 assertThrows("RegExp.prototype.toString.call(false)", TypeError); |
| 721 assertThrows("RegExp.prototype.toString.call(true)", TypeError); | 721 assertThrows("RegExp.prototype.toString.call(true)", TypeError); |
| 722 | 722 |
| 723 // Test mutually recursive capture and backreferences. | 723 // Test mutually recursive capture and backreferences. |
| 724 assertEquals(["b", "", ""], /(\2)b(\1)/.exec("aba")); | 724 assertEquals(["b", "", ""], /(\2)b(\1)/.exec("aba")); |
| 725 assertEquals(["a", "", ""], /(\2).(\1)/.exec("aba")); | 725 assertEquals(["a", "", ""], /(\2).(\1)/.exec("aba")); |
| 726 assertEquals(["aba", "a", "a"], /(.\2).(\1)/.exec("aba")); | 726 assertEquals(["aba", "a", "a"], /(.\2).(\1)/.exec("aba")); |
| 727 assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)$/.exec("acbc")); | 727 assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)$/.exec("acbc")); |
| 728 assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)/.exec("aabcacbc")); | 728 assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)/.exec("aabcacbc")); |
| OLD | NEW |