| 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"], log); | 567 assertEquals(["ts", "li"], 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"], log); | 574 assertEquals(["ts", "li"], 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"], log); | 581 assertEquals(["ts", "li"], 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 assertEquals(-0, re.lastIndex); | 757 assertEquals(-0, re.lastIndex); |
| 758 "abc".search(re); | 758 "abc".search(re); |
| 759 assertEquals(-0, re.lastIndex); | 759 assertEquals(-0, re.lastIndex); |
| 760 | 760 |
| 761 var re = /./; | 761 var re = /./; |
| 762 re.exec = function(str) { assertEquals(0, re.lastIndex); return []; } | 762 re.exec = function(str) { assertEquals(0, re.lastIndex); return []; } |
| 763 re.lastIndex = NaN; | 763 re.lastIndex = NaN; |
| 764 assertEquals(NaN, re.lastIndex); | 764 assertEquals(NaN, re.lastIndex); |
| 765 "abc".search(re); | 765 "abc".search(re); |
| 766 assertEquals(NaN, re.lastIndex); | 766 assertEquals(NaN, re.lastIndex); |
| OLD | NEW |