• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3// found in the LICENSE file.
4
5// Should not time out.  Running time 0.5s vs. 120s before the change.
6function collapse(flags) {
7  var src = "(?:";
8  for (var i = 128; i < 0x1000; i++) {
9    src += String.fromCharCode(96 + i % 26) + String.fromCharCode(i) + "|";
10  }
11  src += "aa)";
12  var collapsible = new RegExp(src, flags);
13  var subject = "zzzzzzz" + String.fromCharCode(3000);
14  for (var i = 0; i < 1000; i++) {
15    subject += "xxxxxxx";
16  }
17  for (var i = 0; i < 2000; i++) {
18    assertFalse(collapsible.test(subject));
19  }
20}
21
22collapse("i");
23collapse("");
24