Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1719)

Side by Side Diff: test/mjsunit/regexp.js

Issue 2339443002: [regexp] Avoid unneeded accesses to lastIndex (Closed)
Patch Set: Update test262 status Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/regexp.js ('k') | test/mjsunit/regress/regress-2437.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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"));
OLDNEW
« no previous file with comments | « src/js/regexp.js ('k') | test/mjsunit/regress/regress-2437.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698