michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 280769; michael@0: var summary = 'Do not overflow 64K length of char sequence in RegExp []'; michael@0: var actual = 'No Crash'; michael@0: var expect = 'No Crash'; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: michael@0: var N = 20 * 1000; // It should be that N*6 > 64K and N < 32K michael@0: michael@0: var prefixes = ["000", "00", "0"]; michael@0: michael@0: function to_4_hex(i) michael@0: { michael@0: var printed = i.toString(16); michael@0: if (printed.length < 4) { michael@0: printed= prefixes[printed.length - 1]+printed; michael@0: } michael@0: return printed; michael@0: michael@0: } michael@0: michael@0: var a = new Array(N); michael@0: for (var i = 0; i != N; ++i) { michael@0: a[i] = to_4_hex(2*i); michael@0: } michael@0: michael@0: var str = '[\\u'+a.join('\\u')+']'; michael@0: // str is [\u0000\u0002\u0004...\u] michael@0: michael@0: var re = new RegExp(str); michael@0: michael@0: var string_to_match = String.fromCharCode(2 * (N - 1)); michael@0: michael@0: var value = re.exec(string_to_match); michael@0: michael@0: var expect = string_to_match; michael@0: var actual = value ? value[0] : value; michael@0: michael@0: reportCompare(expect, actual, summary);