| 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);
|
|
|
|
|