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

Unified Diff: test/mjsunit/regress/regress-2438.js

Issue 11451005: Fix spec violations related to regexp.lastIndex (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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/regress/regress-2437.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-2438.js
diff --git a/test/mjsunit/compiler/optimized-closures.js b/test/mjsunit/regress/regress-2438.js
similarity index 72%
copy from test/mjsunit/compiler/optimized-closures.js
copy to test/mjsunit/regress/regress-2438.js
index eaf75f8d00ccd9123ed0f5232a91137845fc3973..3f4fd7df5723f4e8f3833fe0af9a534bc4172db1 100644
--- a/test/mjsunit/compiler/optimized-closures.js
+++ b/test/mjsunit/regress/regress-2438.js
@@ -25,33 +25,28 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax
-
-// Test optimized closures.
-
-var a = new Array(100);
-
-function f() {
- var x=0;
- for (var i=0; i<100; i++) {
- var g = function goo(y) {
- function h() {
- if (goo.arguments[0] == 23) return -42;
- return 42;
- }
- return x + y + h(y);
- }
- g(0);
- %OptimizeFunctionOnNextCall(g);
- a[i] = g(i);
- }
+function testSideEffects(subject, re) {
+ var counter = 0;
+ var side_effect_object = { valueOf: function() { return counter++; } };
+ re.lastIndex = side_effect_object;
+ re.exec(subject);
+ assertEquals(1, counter);
+
+ re.lastIndex = side_effect_object;
+ re.test(subject);
+ assertEquals(2, counter);
+
+ re.lastIndex = side_effect_object;
+ subject.match(re);
+ assertEquals(3, counter);
+
+ re.lastIndex = side_effect_object;
+ subject.replace(re, "");
+ assertEquals(4, counter);
}
-f();
-assertEquals(42, a[0]);
-assertEquals(49, a[7]);
-assertEquals(-19, a[23]);
-
-
-
+testSideEffects("zzzz", /a/);
+testSideEffects("zzzz", /a/g);
+testSideEffects("xaxa", /a/);
+testSideEffects("xaxa", /a/g);
« no previous file with comments | « test/mjsunit/regress/regress-2437.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698