2 File Name: regexp-enumerate-001.js
4 Description: Regression Test.
6 If instance Native Object have properties that are enumerable,
7 JavaScript enumerated through the properties twice. This only
8 happened if objects had been instantiated, but their properties
9 had not been enumerated. ie, the object inherited properties
10 from its prototype that are enumerated.
12 In the core JavaScript, this is only a problem with RegExp
13 objects, since the inherited properties of most core JavaScript
14 objects are not enumerated.
16 Author: christine@netscape.com, pschwartau@netscape.com
17 Date: 12 November 1997
18 Modified: 14 July 2002
19 Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291
20 ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5
21 RegExp properties should be DontEnum
26 var SECTION = "regexp-enumerate-001";
27 var VERSION = "ECMA_2";
28 var TITLE = "Regression Test for Enumerating Properties";
30 var BUGNUMBER="339403";
33 writeHeaderToLog( SECTION + " "+ TITLE);
36 var testcases = new Array();
39 * This test expects RegExp instances to have four enumerated properties:
40 * source, global, ignoreCase, and lastIndex
42 * 99.01.25: now they also have a multiLine instance property.
51 var t = new TestRegExp();
53 for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) };
55 testcases[testcases.length] = new TestCase( SECTION,
56 "r = new RegExp(); e = new Array(); "+
57 "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length",
63 function TestRegExp() {
64 this.addProperty = addProperty;
66 function addProperty(name, value) {
69 if ( eval("this."+name) != void 0 ) {
72 eval( "this."+ name+" = "+ false );
75 testcases[testcases.length] = new TestCase( SECTION,
76 "Property: " + name +" already enumerated?",
80 if ( testcases[ testcases.length-1].passed == false ) {
81 testcases[testcases.length-1].reason = "property already enumerated";
87 for ( tc=0; tc < testcases.length; tc++ ) {
88 testcases[tc].passed = writeTestCaseResult(
91 testcases[tc].description +" = "+
92 testcases[tc].actual );
94 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";