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-001.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: var SECTION = "RegExp/properties-001.js"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "Properties of RegExp Instances"; michael@0: var BUGNUMBER =""; michael@0: michael@0: startTest(); michael@0: michael@0: AddRegExpCases( new RegExp, "", false, false, false, 0 ); michael@0: AddRegExpCases( /.*/, ".*", false, false, false, 0 ); michael@0: AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); michael@0: AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); michael@0: AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); michael@0: AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); michael@0: AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); michael@0: AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); michael@0: michael@0: AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); michael@0: AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); michael@0: AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); michael@0: michael@0: test(); 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: /* michael@0: * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed michael@0: * the behavior of toString() and toSource() on empty regexps. michael@0: * So branch if |s| is the empty string - michael@0: */ michael@0: var S = s? s : '(?:)'; 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: }