Index: test/mjsunit/regress/regress-2438.js |
diff --git a/test/mjsunit/regress/regress-2438.js b/test/mjsunit/regress/regress-2438.js |
index f694ff8e190765a9782770ef3c9b52c75cada0f0..51092788ac6f7fb8824f4df1e44f37f45cffd650 100644 |
--- a/test/mjsunit/regress/regress-2438.js |
+++ b/test/mjsunit/regress/regress-2438.js |
@@ -27,14 +27,20 @@ |
function testSideEffects(subject, re) { |
var counter = 0; |
+ var expected_counter = 0; |
+ const accesses_lastindex = (re.global || re.sticky); |
var side_effect_object = { valueOf: function() { return counter++; } }; |
re.lastIndex = side_effect_object; |
re.exec(subject); |
- assertEquals(1, counter); |
+ |
+ if (accesses_lastindex) expected_counter++; |
+ assertEquals(expected_counter, counter); |
re.lastIndex = side_effect_object; |
re.test(subject); |
- assertEquals(2, counter); |
+ |
+ if (accesses_lastindex) expected_counter++; |
+ assertEquals(expected_counter, counter); |
} |
testSideEffects("zzzz", /a/); |