| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Should not time out. Running time 0.5s vs. 120s before the change. | 5 // Should not time out. Running time 0.5s vs. 120s before the change. |
| 6 function collapse() { | 6 function collapse(flags) { |
| 7 var src = "(?:"; | 7 var src = "(?:"; |
| 8 for (var i = 128; i < 0x1000; i++) { | 8 for (var i = 128; i < 0x1000; i++) { |
| 9 src += "a" + String.fromCharCode(i) + "|"; | 9 src += String.fromCharCode(96 + i % 26) + String.fromCharCode(i) + "|"; |
| 10 } | 10 } |
| 11 src += "aa)"; | 11 src += "aa)"; |
| 12 var collapsible = new RegExp(src); | 12 var collapsible = new RegExp(src, flags); |
| 13 var subject = "zzzzzzz" + String.fromCharCode(3000); | 13 var subject = "zzzzzzz" + String.fromCharCode(3000); |
| 14 for (var i = 0; i < 1000; i++) { | 14 for (var i = 0; i < 1000; i++) { |
| 15 subject += "xxxxxxx"; | 15 subject += "xxxxxxx"; |
| 16 } | 16 } |
| 17 for (var i = 0; i < 2000; i++) { | 17 for (var i = 0; i < 2000; i++) { |
| 18 assertFalse(collapsible.test(subject)); | 18 assertFalse(collapsible.test(subject)); |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 collapse(); | 22 collapse("i"); |
| 23 collapse(""); |
| OLD | NEW |