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

Unified Diff: test/mjsunit/es6/regexp-replace-lastindex.js

Issue 1410753002: Do not coerce lastIndex of a global RegExp in @@match and @@replace. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/es6/regexp-match-lastindex.js ('k') | test/mjsunit/regress/regress-2438.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/regexp-replace-lastindex.js
diff --git a/test/mjsunit/es6/regexp-replace-lastindex.js b/test/mjsunit/es6/regexp-replace-lastindex.js
new file mode 100644
index 0000000000000000000000000000000000000000..08217e63896bbd43b3a10945db6d5d1bd6a4df44
--- /dev/null
+++ b/test/mjsunit/es6/regexp-replace-lastindex.js
@@ -0,0 +1,11 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Tests that lastIndex of a global RegExp is overwritten as per
+// ECMA-262 6.0 21.2.5.8 step 10.c.
+
+var global = /./g;
+global.lastIndex = { valueOf: function() { assertUnreachable(); } };
+assertEquals("X", "x".replace(global, function(a) { return "X"; }));
+assertEquals(0, global.lastIndex);
« no previous file with comments | « test/mjsunit/es6/regexp-match-lastindex.js ('k') | test/mjsunit/regress/regress-2438.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698