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: /** michael@0: * File Name: RegExp/properties-002.js michael@0: * ECMA Section: 15.7.6.js michael@0: * Description: Based on ECMA 2 Draft 7 February 1999 michael@0: * michael@0: * Author: christine@netscape.com michael@0: * Date: 19 February 1999 michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var SECTION = "RegExp/properties-002.js"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "Properties of RegExp Instances"; michael@0: var BUGNUMBER ="124339"; michael@0: michael@0: startTest(); michael@0: michael@0: re_1 = /\cA?/g; michael@0: re_1.lastIndex = Math.pow(2,31); michael@0: AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); michael@0: michael@0: re_2 = /\w*/i; michael@0: re_2.lastIndex = Math.pow(2,32) -1; michael@0: AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); michael@0: michael@0: re_3 = /\*{0,80}/m; michael@0: re_3.lastIndex = Math.pow(2,31) -1; michael@0: AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); michael@0: michael@0: re_4 = /^./gim; michael@0: re_4.lastIndex = Math.pow(2,30) -1; michael@0: AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); michael@0: michael@0: re_5 = /\B/; michael@0: re_5.lastIndex = Math.pow(2,30); michael@0: AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); michael@0: michael@0: /* michael@0: * Brendan: "need to test cases Math.pow(2,32) and greater to see michael@0: * whether they round-trip." Reason: thanks to the work done in michael@0: * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex michael@0: * is now stored as a double instead of a uint32_t (unsigned integer). michael@0: * michael@0: * Note 2^32 -1 is the upper bound for uint32's, but doubles can go michael@0: * all the way up to Number.MAX_VALUE. So that's why we need cases michael@0: * between those two numbers. michael@0: * michael@0: */ michael@0: re_6 = /\B/; michael@0: re_6.lastIndex = Math.pow(2,32); michael@0: AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); michael@0: michael@0: re_7 = /\B/; michael@0: re_7.lastIndex = Math.pow(2,32) + 1; michael@0: AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); michael@0: michael@0: re_8 = /\B/; michael@0: re_8.lastIndex = Math.pow(2,32) * 2; michael@0: AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); michael@0: michael@0: re_9 = /\B/; michael@0: re_9.lastIndex = Math.pow(2,40); michael@0: AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); michael@0: michael@0: re_10 = /\B/; michael@0: re_10.lastIndex = Number.MAX_VALUE; michael@0: AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); michael@0: michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: michael@0: michael@0: function AddRegExpCases( re, s, g, i, m, l ){ michael@0: michael@0: AddTestCase( re + ".test == RegExp.prototype.test", michael@0: true, michael@0: re.test == RegExp.prototype.test ); michael@0: michael@0: AddTestCase( re + ".toString == RegExp.prototype.toString", michael@0: true, michael@0: re.toString == RegExp.prototype.toString ); michael@0: michael@0: AddTestCase( re + ".contructor == RegExp.prototype.constructor", michael@0: true, michael@0: re.constructor == RegExp.prototype.constructor ); michael@0: michael@0: AddTestCase( re + ".compile == RegExp.prototype.compile", michael@0: true, michael@0: re.compile == RegExp.prototype.compile ); michael@0: michael@0: AddTestCase( re + ".exec == RegExp.prototype.exec", michael@0: true, michael@0: re.exec == RegExp.prototype.exec ); michael@0: michael@0: // properties michael@0: michael@0: AddTestCase( re + ".source", michael@0: s, michael@0: re.source ); michael@0: michael@0: AddTestCase( re + ".toString()", michael@0: "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), michael@0: re.toString() ); michael@0: michael@0: AddTestCase( re + ".global", michael@0: g, michael@0: re.global ); michael@0: michael@0: AddTestCase( re + ".ignoreCase", michael@0: i, michael@0: re.ignoreCase ); michael@0: michael@0: AddTestCase( re + ".multiline", michael@0: m, michael@0: re.multiline); michael@0: michael@0: AddTestCase( re + ".lastIndex", michael@0: l, michael@0: re.lastIndex ); michael@0: }