]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js
JavaScriptCore-461.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_2 / RegExp / regexp-enumerate-001.js
CommitLineData
b37bf2e1
A
1/**
2 File Name: regexp-enumerate-001.js
3 ECMA V2 Section:
4 Description: Regression Test.
5
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.
11
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.
15
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
22*
23*/
24// onerror = err;
25
26 var SECTION = "regexp-enumerate-001";
27 var VERSION = "ECMA_2";
28 var TITLE = "Regression Test for Enumerating Properties";
29
30 var BUGNUMBER="339403";
31
32 startTest();
33 writeHeaderToLog( SECTION + " "+ TITLE);
34
35 var tc = 0;
36 var testcases = new Array();
37
38 /*
39 * This test expects RegExp instances to have four enumerated properties:
40 * source, global, ignoreCase, and lastIndex
41 *
42 * 99.01.25: now they also have a multiLine instance property.
43 *
44 */
45
46
47 var r = new RegExp();
48
49 var e = new Array();
50
51 var t = new TestRegExp();
52
53 for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) };
54
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",
58 0,
59 e.length );
60
61 test();
62
63function TestRegExp() {
64 this.addProperty = addProperty;
65}
66function addProperty(name, value) {
67 var pass = false;
68
69 if ( eval("this."+name) != void 0 ) {
70 pass = true;
71 } else {
72 eval( "this."+ name+" = "+ false );
73 }
74
75 testcases[testcases.length] = new TestCase( SECTION,
76 "Property: " + name +" already enumerated?",
77 false,
78 pass );
79
80 if ( testcases[ testcases.length-1].passed == false ) {
81 testcases[testcases.length-1].reason = "property already enumerated";
82
83 }
84
85}
86function test() {
87 for ( tc=0; tc < testcases.length; tc++ ) {
88 testcases[tc].passed = writeTestCaseResult(
89 testcases[tc].expect,
90 testcases[tc].actual,
91 testcases[tc].description +" = "+
92 testcases[tc].actual );
93
94 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
95 }
96 stopTest();
97 return ( testcases );
98}