michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var BUGNUMBER = 805121; michael@0: var summary = "Be more careful with string math to avoid wrong results"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: function puff(x, n) michael@0: { michael@0: while(x.length < n) michael@0: x += x; michael@0: return x.substring(0, n); michael@0: } michael@0: michael@0: var x = puff("1", 1 << 20); michael@0: var rep = puff("$1", 1 << 16); michael@0: michael@0: try michael@0: { michael@0: var y = x.replace(/(.+)/g, rep); michael@0: assertEq(y.length, Math.pow(2, 36)); michael@0: } michael@0: catch (e) michael@0: { michael@0: // OOM also acceptable michael@0: } michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");