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

Side by Side Diff: test/mjsunit/regress/regress-2438.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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/es6/regexp-replace-lastindex.js ('k') | no next file » | 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 17 matching lines...) Expand all
28 function testSideEffects(subject, re) { 28 function testSideEffects(subject, re) {
29 var counter = 0; 29 var counter = 0;
30 var side_effect_object = { valueOf: function() { return counter++; } }; 30 var side_effect_object = { valueOf: function() { return counter++; } };
31 re.lastIndex = side_effect_object; 31 re.lastIndex = side_effect_object;
32 re.exec(subject); 32 re.exec(subject);
33 assertEquals(1, counter); 33 assertEquals(1, counter);
34 34
35 re.lastIndex = side_effect_object; 35 re.lastIndex = side_effect_object;
36 re.test(subject); 36 re.test(subject);
37 assertEquals(2, counter); 37 assertEquals(2, counter);
38
39 re.lastIndex = side_effect_object;
40 subject.match(re);
41 assertEquals(3, counter);
42
43 re.lastIndex = side_effect_object;
44 subject.replace(re, "");
45 assertEquals(4, counter);
46 } 38 }
47 39
48 testSideEffects("zzzz", /a/); 40 testSideEffects("zzzz", /a/);
49 testSideEffects("zzzz", /a/g); 41 testSideEffects("zzzz", /a/g);
50 testSideEffects("xaxa", /a/); 42 testSideEffects("xaxa", /a/);
51 testSideEffects("xaxa", /a/g); 43 testSideEffects("xaxa", /a/g);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/regexp-replace-lastindex.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698