dart-sdk/tests/corelib/regexp/jemalloc_leak_backtracking_stack_test.dart
Robert Nystrom 4eda30c5c2 Migrate corelib_2/regexp files to NNBD.
Change-Id: I5bacd28d806661b9190d4b097955263a56f19a4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128110
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2019-12-18 16:16:51 +00:00

25 lines
712 B
Dart

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Regression test for https://github.com/flutter/flutter/issues/29007
String escape(String string) {
var regex = new RegExp("(\\?|\\\$|\\*|\\(|\\)|\\[)|\\+|\\.|\\\\");
return string.replaceAllMapped(
regex, (Match m) => "\\" + string.substring(m.start, m.end));
}
main() {
var text = """
Yet but three? Come one more.
Two of both kinds make up four.
""";
var accumulate = 0;
for (var i = 0; i < 65536; i++) {
accumulate += escape(text).length;
}
print(accumulate);
}