Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / chrome / test / data / dromaeo / tests / dromaeo-object-regexp.html
blobfe36ccdd27b30e4f332674714e1dda3620be9750
1 <html>
2 <head>
3 <script src="../htmlrunner.js"></script>
4 <script>
5 window.onload = function(){ startTest("dromaeo-object-regexp", '812dde38');
7 // Try to force real results
8 var str = [], tmp, ret, re, testStrings = [];
9 var i = 65536;
11 function randomChar(){
12 return String.fromCharCode( (25 * Math.random()) + 97 );
15 for ( var i = 0; i < 16384; i++ )
16 str.push( randomChar() );
18 str = str.join("");
19 str += str;
20 str += str;
22 function generateTestStrings(count){
23 var t, nest;
24 if ( testStrings.length >= count )
25 return testStrings.slice(0, count);
26 for ( var i = testStrings.length; i < count; i++ ) {
27 // Make all tested strings different
28 t = randomChar() + str + randomChar();
29 nest = Math.floor(4 * Math.random());
30 for ( var j = 0; j < nest; j++ ) {
31 t = randomChar() + t + randomChar();
33 // Try to minimize benchmark order dependencies by
34 // exercising the strings
35 for ( var j = 0; j < t.length; j += 100 ) {
36 ret = t[j];
37 ret = t.substring(j, j + 100);
39 testStrings[i] = t;
41 return testStrings;
44 // TESTS: split
46 prep(function(){
47 // It's impossible to specify empty regexp by simply
48 // using two slashes as this will be interpreted as a
49 // comment start. See note to ECMA-262 5th 7.8.5.
50 re = /(?:)/;
51 tmp = generateTestStrings(30);
52 });
54 test( "Compiled Object Empty Split", function(){
55 for ( var i = 0; i < 30; i++ )
56 ret = tmp[i].split( re );
57 });
59 prep(function(){
60 re = /a/;
61 tmp = generateTestStrings(30);
62 });
64 test( "Compiled Object Char Split", function(){
65 for ( var i = 0; i < 30; i++ )
66 ret = tmp[i].split( re );
67 });
69 prep(function(){
70 re = /.*/;
71 tmp = generateTestStrings(100);
72 });
74 test( "Compiled Object Variable Split", function(){
75 for ( var i = 0; i < 100; i++ )
76 ret = tmp[i].split( re );
77 });
79 // TESTS: Compiled RegExps
81 prep(function(){
82 re = /aaaaaaaaaa/g;
83 tmp = generateTestStrings(100);
84 });
86 test( "Compiled Match", function(){
87 for ( var i = 0; i < 100; i++ )
88 ret = tmp[i].match( re );
89 });
91 prep(function(){
92 tmp = generateTestStrings(100);
93 });
95 test( "Compiled Test", function(){
96 for ( var i = 0; i < 100; i++ )
97 ret = re.test( tmp[i] );
98 });
100 prep(function(){
101 tmp = generateTestStrings(100);
104 test( "Compiled Empty Replace", function(){
105 for ( var i = 0; i < 50; i++ )
106 ret = tmp[i].replace( re, "" );
109 prep(function(){
110 tmp = generateTestStrings(50);
113 test( "Compiled 12 Char Replace", function(){
114 for ( var i = 0; i < 50; i++ )
115 ret = tmp[i].replace( re, "asdfasdfasdf" );
118 prep(function(){
119 re = new RegExp("aaaaaaaaaa", "g");
120 tmp = generateTestStrings(100);
123 test( "Compiled Object Match", function(){
124 for ( var i = 0; i < 100; i++ )
125 ret = tmp[i].match( re );
128 prep(function(){
129 tmp = generateTestStrings(100);
132 test( "Compiled Object Test", function(){
133 for ( var i = 0; i < 100; i++ )
134 ret = re.test( tmp[i] );
137 prep(function(){
138 tmp = generateTestStrings(50);
141 test( "Compiled Object Empty Replace", function(){
142 for ( var i = 0; i < 50; i++ )
143 ret = tmp[i].replace( re, "" );
146 prep(function(){
147 tmp = generateTestStrings(50);
150 test( "Compiled Object 12 Char Replace", function(){
151 for ( var i = 0; i < 50; i++ )
152 ret = tmp[i].replace( re, "asdfasdfasdf" );
155 prep(function(){
156 tmp = generateTestStrings(50);
159 test( "Compiled Object 12 Char Replace Function", function(){
160 for ( var i = 0; i < 50; i++ )
161 ret = tmp[i].replace( re, function(all){
162 return "asdfasdfasdf";
166 // TESTS: Variable Length
168 prep(function(){
169 re = /a.*a/;
170 tmp = generateTestStrings(100);
173 test( "Compiled Variable Match", function(){
174 for ( var i = 0; i < 100; i++ )
175 ret = tmp[i].match( re );
178 prep(function(){
179 tmp = generateTestStrings(100);
182 test( "Compiled Variable Test", function(){
183 for ( var i = 0; i < 100; i++ )
184 ret = re.test( tmp[i] );
187 prep(function(){
188 tmp = generateTestStrings(50);
191 test( "Compiled Variable Empty Replace", function(){
192 for ( var i = 0; i < 50; i++ )
193 ret = tmp[i].replace( re, "" );
196 prep(function(){
197 tmp = generateTestStrings(50);
200 test( "Compiled Variable 12 Char Replace", function(){
201 for ( var i = 0; i < 50; i++ )
202 ret = tmp[i].replace( re, "asdfasdfasdf" );
205 prep(function(){
206 re = new RegExp("aaaaaaaaaa", "g");
207 tmp = generateTestStrings(100);
210 test( "Compiled Variable Object Match", function(){
211 for ( var i = 0; i < 100; i++ )
212 ret = tmp[i].match( re );
215 prep(function(){
216 tmp = generateTestStrings(100);
219 test( "Compiled Variable Object Test", function(){
220 for ( var i = 0; i < 100; i++ )
221 ret = re.test( tmp[i] );
224 prep(function(){
225 tmp = generateTestStrings(50);
228 test( "Compiled Variable Object Empty Replace", function(){
229 for ( var i = 0; i < 50; i++ )
230 ret = tmp[i].replace( re, "" );
233 prep(function(){
234 tmp = generateTestStrings(50);
237 test( "Compiled Variable Object 12 Char Replace", function(){
238 for ( var i = 0; i < 50; i++ )
239 ret = tmp[i].replace( re, "asdfasdfasdf" );
242 prep(function(){
243 tmp = generateTestStrings(50);
246 test( "Compiled Variable Object 12 Char Replace Function", function(){
247 for ( var i = 0; i < 50; i++ )
248 ret = tmp[i].replace( re, function(all){
249 return "asdfasdfasdf";
253 // TESTS: Capturing
255 prep(function(){
256 re = /aa(b)aa/g;
257 tmp = generateTestStrings(100);
260 test( "Compiled Capture Match", function(){
261 for ( var i = 0; i < 100; i++ )
262 ret = tmp[i].match( re );
265 prep(function(){
266 tmp = generateTestStrings(50);
269 test( "Compiled Capture Replace", function(){
270 for ( var i = 0; i < 50; i++ )
271 ret = tmp[i].replace( re, "asdfasdfasdf" );
274 prep(function(){
275 tmp = generateTestStrings(50);
278 test( "Compiled Capture Replace with Capture", function(){
279 for ( var i = 0; i < 50; i++ )
280 ret = tmp[i].replace( re, "asdf\\1asdfasdf" );
283 prep(function(){
284 tmp = generateTestStrings(50);
287 test( "Compiled Capture Replace with Capture Function", function(){
288 for ( var i = 0; i < 50; i++ )
289 ret = tmp[i].replace( re, function(all,capture){
290 return "asdf" + capture + "asdfasdf";
294 prep(function(){
295 tmp = generateTestStrings(50);
298 test( "Compiled Capture Replace with Upperase Capture Function", function(){
299 for ( var i = 0; i < 50; i++ )
300 ret = tmp[i].replace( re, function(all,capture){
301 return capture.toUpperCase();
305 // TESTS: Uncompiled RegExps
307 prep(function(){
308 tmp = generateTestStrings(100);
311 test( "Uncompiled Match", function(){
312 for ( var i = 0; i < 100; i++ )
313 ret = tmp[i].match( /aaaaaaaaaa/g );
316 prep(function(){
317 tmp = generateTestStrings(100);
320 test( "Uncompiled Test", function(){
321 for ( var i = 0; i < 100; i++ )
322 ret = (/aaaaaaaaaa/g).test( tmp[i] );
325 prep(function(){
326 tmp = generateTestStrings(50);
329 test( "Uncompiled Empty Replace", function(){
330 for ( var i = 0; i < 50; i++ )
331 ret = tmp[i].replace( /aaaaaaaaaa/g, "" );
334 prep(function(){
335 tmp = generateTestStrings(50);
338 test( "Uncompiled 12 Char Replace", function(){
339 for ( var i = 0; i < 50; i++ )
340 ret = tmp[i].replace( /aaaaaaaaaa/g, "asdfasdfasdf" );
343 prep(function(){
344 tmp = generateTestStrings(100);
347 test( "Uncompiled Object Match", function(){
348 for ( var i = 0; i < 100; i++ )
349 ret = tmp[i].match( new RegExp("aaaaaaaaaa", "g") );
352 prep(function(){
353 tmp = generateTestStrings(100);
356 test( "Uncompiled Object Test", function(){
357 for ( var i = 0; i < 100; i++ )
358 ret = (new RegExp("aaaaaaaaaa", "g")).test( tmp[i] );
361 prep(function(){
362 tmp = generateTestStrings(50);
365 test( "Uncompiled Object Empty Replace", function(){
366 for ( var i = 0; i < 50; i++ )
367 ret = tmp[i].replace( new RegExp("aaaaaaaaaa", "g"), "" );
370 prep(function(){
371 tmp = generateTestStrings(50);
374 test( "Uncompiled Object 12 Char Replace", function(){
375 for ( var i = 0; i < 50; i++ )
376 ret = tmp[i].replace( new RegExp("aaaaaaaaaa", "g"), "asdfasdfasdf" );
379 endTest(); };
380 </script>
381 </head>
382 <body></body>
383 </html>