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

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

Issue 1418703003: RegExp: remove last match info override. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 assertEquals('012', RegExp['$3']); 112 assertEquals('012', RegExp['$3']);
113 for (var i = 4; i < 10; ++i) { 113 for (var i = 4; i < 10; ++i) {
114 assertEquals('', RegExp['$' + i]); 114 assertEquals('', RegExp['$' + i]);
115 } 115 }
116 116
117 // String.prototype.replace must interleave matching and replacing when a 117 // String.prototype.replace must interleave matching and replacing when a
118 // global regexp is matched and replaced with the result of a function, in 118 // global regexp is matched and replaced with the result of a function, in
119 // case the function uses the static properties of the regexp constructor. 119 // case the function uses the static properties of the regexp constructor.
120 re = /(.)/g; 120 re = /(.)/g;
121 function f() { return RegExp.$1; }; 121 function f() { return RegExp.$1; };
122 assertEquals('abcd', 'abcd'.replace(re, f)); 122 assertEquals('dddd', 'abcd'.replace(re, f));
123 123
124 // lastParen where the last parenthesis didn't match. 124 // lastParen where the last parenthesis didn't match.
125 assertEquals(["foo",undefined], /foo(?:a(x))?/.exec("foobx"), 125 assertEquals(["foo",undefined], /foo(?:a(x))?/.exec("foobx"),
126 "lastParen setup"); 126 "lastParen setup");
127 assertEquals("", RegExp.lastParen, "lastParen"); 127 assertEquals("", RegExp.lastParen, "lastParen");
128 128
129 // The same test for $1 to $9. 129 // The same test for $1 to $9.
130 for (var i = 1; i <= 9; i++) { 130 for (var i = 1; i <= 9; i++) {
131 var haystack = "foo"; 131 var haystack = "foo";
132 var re_text = "^foo"; 132 var re_text = "^foo";
(...skipping 19 matching lines...) Expand all
152 // Ensure that we save the correct string as the last subject when 152 // Ensure that we save the correct string as the last subject when
153 // we do a match on a sliced string (the top one not the underlying). 153 // we do a match on a sliced string (the top one not the underlying).
154 var foo = "lsdfj sldkfj sdklfj læsdfjl sdkfjlsdk fjsdl fjsdljskdj flsj flsdkj fl skd regexp: /foobar/\nldkfj sdlkfj sdkl"; 154 var foo = "lsdfj sldkfj sdklfj læsdfjl sdkfjlsdk fjsdl fjsdljskdj flsj flsdkj fl skd regexp: /foobar/\nldkfj sdlkfj sdkl";
155 assertTrue(/^([a-z]+): (.*)/.test(foo.substring(foo.indexOf("regexp:"))), "regex p: setup"); 155 assertTrue(/^([a-z]+): (.*)/.test(foo.substring(foo.indexOf("regexp:"))), "regex p: setup");
156 assertEquals("regexp", RegExp.$1, "RegExp.$1"); 156 assertEquals("regexp", RegExp.$1, "RegExp.$1");
157 157
158 158
159 // Check that calling with no argument is the same as calling with undefined. 159 // Check that calling with no argument is the same as calling with undefined.
160 assertTrue(/^undefined$/.test()); 160 assertTrue(/^undefined$/.test());
161 assertEquals(["undefined"], /^undefined$/.exec()); 161 assertEquals(["undefined"], /^undefined$/.exec());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698