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

Unified Diff: test/mjsunit/regexp-capture-3.js

Issue 10105026: Version 3.10.3 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/mjsunit.js ('k') | test/mjsunit/regress/regress-1119.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regexp-capture-3.js
===================================================================
--- test/mjsunit/regexp-capture-3.js (revision 11348)
+++ test/mjsunit/regexp-capture-3.js (working copy)
@@ -25,6 +25,64 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"abcd".replace(/b/g, function() { });
+function oneMatch(re) {
+ "abcd".replace(re, function() { });
+ assertEquals("abcd", RegExp.input);
+ assertEquals("a", RegExp.leftContext);
+ assertEquals("b", RegExp.lastMatch);
+ assertEquals("", RegExp.lastParen);
+ assertEquals(undefined, RegExp.lastIndex);
+ assertEquals(undefined, RegExp.index);
+ assertEquals("cd", RegExp.rightContext);
+ for (var i = 1; i < 10; i++) {
+ assertEquals("", RegExp['$' + i]);
+ }
+}
+oneMatch(/b/);
+oneMatch(/b/g);
+
+"abcdabcd".replace(/b/g, function() { });
+assertEquals("abcdabcd", RegExp.input);
+assertEquals("abcda", RegExp.leftContext);
+assertEquals("b", RegExp.lastMatch);
+assertEquals("", RegExp.lastParen);
+assertEquals(undefined, RegExp.lastIndex);
+assertEquals(undefined, RegExp.index);
assertEquals("cd", RegExp.rightContext);
+for (var i = 1; i < 10; i++) {
+ assertEquals("", RegExp['$' + i]);
+}
+
+function captureMatch(re) {
+ "abcd".replace(re, function() { });
+ assertEquals("abcd", RegExp.input);
+ assertEquals("a", RegExp.leftContext);
+ assertEquals("bc", RegExp.lastMatch);
+ assertEquals("c", RegExp.lastParen);
+ assertEquals(undefined, RegExp.lastIndex);
+ assertEquals(undefined, RegExp.index);
+ assertEquals("d", RegExp.rightContext);
+ assertEquals('b', RegExp.$1);
+ assertEquals('c', RegExp.$2);
+ for (var i = 3; i < 10; i++) {
+ assertEquals("", RegExp['$' + i]);
+ }
+}
+
+captureMatch(/(b)(c)/);
+captureMatch(/(b)(c)/g);
+
+"abcdabcd".replace(/(b)(c)/g, function() { });
+assertEquals("abcdabcd", RegExp.input);
+assertEquals("abcda", RegExp.leftContext);
+assertEquals("bc", RegExp.lastMatch);
+assertEquals("c", RegExp.lastParen);
+assertEquals(undefined, RegExp.lastIndex);
+assertEquals(undefined, RegExp.index);
+assertEquals("d", RegExp.rightContext);
+assertEquals('b', RegExp.$1);
+assertEquals('c', RegExp.$2);
+for (var i = 3; i < 10; i++) {
+ assertEquals("", RegExp['$' + i]);
+}
« no previous file with comments | « test/mjsunit/mjsunit.js ('k') | test/mjsunit/regress/regress-1119.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698