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-enumerate-001.js michael@0: ECMA V2 Section: michael@0: Description: Regression Test. michael@0: michael@0: If instance Native Object have properties that are enumerable, michael@0: JavaScript enumerated through the properties twice. This only michael@0: happened if objects had been instantiated, but their properties michael@0: had not been enumerated. ie, the object inherited properties michael@0: from its prototype that are enumerated. michael@0: michael@0: In the core JavaScript, this is only a problem with RegExp michael@0: objects, since the inherited properties of most core JavaScript michael@0: objects are not enumerated. michael@0: michael@0: Author: christine@netscape.com, pschwartau@netscape.com michael@0: Date: 12 November 1997 michael@0: Modified: 14 July 2002 michael@0: Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 michael@0: ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 michael@0: RegExp properties should be DontEnum michael@0: * michael@0: */ michael@0: // onerror = err; michael@0: michael@0: var SECTION = "regexp-enumerate-001"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "Regression Test for Enumerating Properties"; michael@0: michael@0: var BUGNUMBER="339403"; michael@0: michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: /* michael@0: * This test expects RegExp instances to have four enumerated properties: michael@0: * source, global, ignoreCase, and lastIndex michael@0: * michael@0: * 99.01.25: now they also have a multiLine instance property. michael@0: * michael@0: */ michael@0: michael@0: michael@0: var r = new RegExp(); michael@0: michael@0: var e = new Array(); michael@0: michael@0: var t = new TestRegExp(); michael@0: michael@0: for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; michael@0: michael@0: new TestCase( SECTION, michael@0: "r = new RegExp(); e = new Array(); "+ michael@0: "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", michael@0: 0, michael@0: e.length ); michael@0: michael@0: test(); michael@0: michael@0: function TestRegExp() { michael@0: this.addProperty = addProperty; michael@0: } michael@0: function addProperty(name, value) { michael@0: var pass = false; michael@0: michael@0: if ( eval("this."+name) != void 0 ) { michael@0: pass = true; michael@0: } else { michael@0: eval( "this."+ name+" = "+ false ); michael@0: } michael@0: michael@0: new TestCase( SECTION, michael@0: "Property: " + name +" already enumerated?", michael@0: false, michael@0: pass ); michael@0: michael@0: if ( gTestcases[ gTestcases.length-1].passed == false ) { michael@0: gTestcases[gTestcases.length-1].reason = "property already enumerated"; michael@0: michael@0: } michael@0: michael@0: }