4 function print(message
)
6 var block
= document
.createElement("div");
7 block
.appendChild(document
.createTextNode(message
));
8 block
.appendChild(document
.createElement("br"));
9 document
.getElementById("console").appendChild(block
);
12 function isReadOnly(object
, property
)
14 var oldValue
= object
[property
];
15 object
[property
] = !object
[property
];
16 var result
= (object
[property
] == oldValue
);
17 object
[property
] = oldValue
;
21 function printPropertiesWithReadOnly(object
)
23 var array
= new Array
;
24 for (var property
in object
) {
28 for (var i
= 0; i
< array
.length
; i
++) {
29 var property
= array
[i
];
30 print(property
+ ": {" + object
[property
] + "} " + (isReadOnly(object
, property
) ? "(read-only)" : "(read-write)"));
34 function printProperties(object
)
36 var array
= new Array
;
37 for (var property
in object
) {
41 for (var i
= 0; i
< array
.length
; i
++) {
42 var property
= array
[i
];
43 print(property
+ ": {" + object
[property
] + "}");
48 if (window
.testRunner
)
49 testRunner
.dumpAsText();
51 print("Properties of RegExp at startup:");
52 printPropertiesWithReadOnly(RegExp
);
54 var r
= /(1)(2)(3)(4)(5)(6)(7)(8)(9)(0)/;
55 var matchingString
= "<1234567890>";
56 var unmatchingString
= "XXX";
58 var dummyRegExp
= new RegExp();
62 r
.exec(matchingString
);
63 print("Properties of RegExp after " + r
+ ".exec(" + matchingString
+ "):");
64 printProperties(RegExp
);
67 print("RegExp.$0 " + (RegExp
.$0 ? "exists" : "does not exist"));
68 print("RegExp.$10 " + (RegExp
.$10 ? "exists" : "does not exist"));
69 print("RegExp " + (r
.test() ? "uses" : "doesn't use") + " RegExp.input");
71 RegExp
.multiline
= "foo";
72 print("RegExp.multiline " + (typeof RegExp
.multiline
== typeof Boolean() ? "coerces" : "doesn't coerce") + " values to booleans");
73 RegExp
.input
= Number();
74 print("RegExp.input " + (typeof RegExp
.input
== typeof String() ? "coerces" : "doesn't coerce") + " values to strings");
77 r
.exec(unmatchingString
);
78 print("Properties of RegExp after " + r
+ ".exec(" + unmatchingString
+ "):");
79 printProperties(RegExp
);
82 print("---------- [Cleared RegExp values] ----------");
83 dummyRegExp
.exec(dummyString
);
84 if (RegExp
.lastMatch
!= "")
85 print("Clear failed");
87 matchingString
.search(r
);
88 print("Properties of RegExp after " + matchingString
+ ".search(" + r
+ "):");
89 printProperties(RegExp
);
92 print("---------- [Cleared RegExp values] ----------");
93 dummyRegExp
.exec(dummyString
);
95 matchingString
.replace(r
);
96 print("Properties of RegExp after " + matchingString
+ ".replace(" + r
+ "):");
97 printProperties(RegExp
);
101 <body onload=
"test();">
103 This test checks our implementation of the special RegExp member variables.
106 <div id='console'/
style=
"font-family: courier; font-size: 12">