Debian Codegraph @

rhino/testsrc/tests/ecma_2/RegExp/regexp-enumerate-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'regexp-enumerate-001.js';
7
8 /**
9 File Name: regexp-enumerate-001.js
10 ECMA V2 Section:
11 Description: Regression Test.
12
13 If instance Native Object have properties that are enumerable,
14 JavaScript enumerated through the properties twice. This only
15 happened if objects had been instantiated, but their properties
16 had not been enumerated. ie, the object inherited properties
17 from its prototype that are enumerated.
18
19 In the core JavaScript, this is only a problem with RegExp
20 objects, since the inherited properties of most core JavaScript
21 objects are not enumerated.
22
23 Author: [email protected], [email protected]
24 Date: 12 November 1997
25 Modified: 14 July 2002
26 Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291
27 ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5
28 RegExp properties should be DontEnum
29 *
30 */
31 // onerror = err;
32
33 var SECTION = "regexp-enumerate-001";
34 var VERSION = "ECMA_2";
35 var TITLE = "Regression Test for Enumerating Properties";
36
37 var BUGNUMBER="339403";
38
39 startTest();
40 writeHeaderToLog( SECTION + " "+ TITLE);
41
42 /*
43 * This test expects RegExp instances to have four enumerated properties:
44 * source, global, ignoreCase, and lastIndex
45 *
46 * 99.01.25: now they also have a multiLine instance property.
47 *
48 */
49
50
51 var r = new RegExp();
52
53 var e = new Array();
54
55 var t = new TestRegExp();
56
57 for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) };
58
59 new TestCase( SECTION,
60 "r = new RegExp(); e = new Array(); "+
61 "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length",
62 0,
63 e.length );
64
65 test();
66
67 function TestRegExp() {
68 this.addProperty = addProperty;
69 }
70 function addProperty(name, value) {
71 var pass = false;
72
73 if ( eval("this."+name) != void 0 ) {
74 pass = true;
75 } else {
76 eval( "this."+ name+" = "+ false );
77 }
78
79 new TestCase( SECTION,
80 "Property: " + name +" already enumerated?",
81 false,
82 pass );
83
84 if ( gTestcases[ gTestcases.length-1].passed == false ) {
85 gTestcases[gTestcases.length-1].reason = "property already enumerated";
86
87 }
88
89 }