2 <!-- MOZ_INSERT_CONTENT_HOOK -->
3 <script src = runner.js
></script>
5 var onlyName
= 'Uncompiled Match', onlyNum
= 65536;
8 startTest("object-regexp");
10 // Try to force real results
11 var str
= "", tmp
, ret
, re
;
13 for ( var i
= 0; i
< 16384; i
++ )
14 str
+= String
.fromCharCode( (25 * Math
.random()) + 97 );
16 for ( var i
= 16384; i
<= 131072; i
*= 2 ) (function(i
){
19 // Note: These tests are really slow, so we're running them for smaller
26 test( "Compiled Object Empty Split", i
, function(){
27 ret
= tmp
.split( re
);
33 test( "Compiled Object Char Split", i
, function(){
34 ret
= tmp
.split( re
);
40 test( "Compiled Object Variable Split", i
, function(){
41 ret
= tmp
.split( re
);
45 // TESTS: Compiled RegExps
51 test( "Compiled Match", i
, function(){
52 ret
= tmp
.match( re
);
57 test( "Compiled Test", i
, function(){
63 test( "Compiled Empty Replace", i
, function(){
64 ret
= tmp
.replace( re
, "" );
69 test( "Compiled 12 Char Replace", i
, function(){
70 ret
= tmp
.replace( re
, "asdfasdfasdf" );
73 re
= new RegExp("aaaaaaaaaa", "g");
77 test( "Compiled Object Match", i
, function(){
78 ret
= tmp
.match( re
);
83 test( "Compiled Object Test", i
, function(){
89 test( "Compiled Object Empty Replace", i
, function(){
90 ret
= tmp
.replace( re
, "" );
95 test( "Compiled Object 12 Char Replace", i
, function(){
96 ret
= tmp
.replace( re
, "asdfasdfasdf" );
101 test( "Compiled Object 12 Char Replace Function", i
, function(){
102 ret
= tmp
.replace( re
, function(all
){
103 return "asdfasdfasdf";
107 // TESTS: Variable Length
113 test( "Compiled Variable Match", i
, function(){
114 ret
= tmp
.match( re
);
119 test( "Compiled Variable Test", i
, function(){
120 ret
= re
.test( tmp
);
125 test( "Compiled Variable Empty Replace", i
, function(){
126 ret
= tmp
.replace( re
, "" );
131 test( "Compiled Variable 12 Char Replace", i
, function(){
132 ret
= tmp
.replace( re
, "asdfasdfasdf" );
135 re
= new RegExp("aaaaaaaaaa", "g");
139 test( "Compiled Variable Object Match", i
, function(){
140 ret
= tmp
.match( re
);
145 test( "Compiled Variable Object Test", i
, function(){
146 ret
= re
.test( tmp
);
151 test( "Compiled Variable Object Empty Replace", i
, function(){
152 ret
= tmp
.replace( re
, "" );
157 test( "Compiled Variable Object 12 Char Replace", i
, function(){
158 ret
= tmp
.replace( re
, "asdfasdfasdf" );
163 test( "Compiled Variable Object 12 Char Replace Function", i
, function(){
164 ret
= tmp
.replace( re
, function(all
){
165 return "asdfasdfasdf";
175 test( "Compiled Capture Match", i
, function(){
176 ret
= tmp
.match( re
);
181 test( "Compiled Capture Replace", i
, function(){
182 ret
= tmp
.replace( re
, "asdfasdfasdf" );
187 test( "Compiled Capture Replace with Capture", i
, function(){
188 ret
= tmp
.replace( re
, "asdf\\1asdfasdf" );
193 test( "Compiled Capture Replace with Capture Function", i
, function(){
194 ret
= tmp
.replace( re
, function(all
,capture
){
195 return "asdf" + capture
+ "asdfasdf";
201 test( "Compiled Capture Replace with Upperase Capture Function", i
, function(){
202 ret
= tmp
.replace( re
, function(all
,capture
){
203 return capture
.toUpperCase();
207 // TESTS: Uncompiled RegExps
211 test( "Uncompiled Match", i
, function(){
212 ret
= tmp
.match( /aaaaaaaaaa/g );
217 test( "Uncompiled Test", i
, function(){
218 ret
= (/aaaaaaaaaa/g).test( tmp
);
223 test( "Uncompiled Empty Replace", i
, function(){
224 ret
= tmp
.replace( /aaaaaaaaaa/g, "" );
229 test( "Uncompiled 12 Char Replace", i
, function(){
230 ret
= tmp
.replace( /aaaaaaaaaa/g, "asdfasdfasdf" );
235 test( "Uncompiled Object Match", i
, function(){
236 ret
= tmp
.match( new RegExp("aaaaaaaaaa", "g") );
241 test( "Uncompiled Object Test", i
, function(){
242 ret
= (new RegExp("aaaaaaaaaa", "g")).test( tmp
);
247 test( "Uncompiled Object Empty Replace", i
, function(){
248 ret
= tmp
.replace( new RegExp("aaaaaaaaaa", "g"), "" );
253 test( "Uncompiled Object 12 Char Replace", i
, function(){
254 ret
= tmp
.replace( new RegExp("aaaaaaaaaa", "g"), "asdfasdfasdf" );
257 // Double the length of the string
264 <body onload=
"thisTest()"></body></html>