Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: tests/corelib/regexp/capture_test.dart

Issue 691473002: Reapply "Port regexp tests from V8 to Dart." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RC and rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/regexp/capture-3_test.dart ('k') | tests/corelib/regexp/captures_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/regexp/capture_test.dart
diff --git a/runtime/third_party/double-conversion/src/diy-fp.cc b/tests/corelib/regexp/capture_test.dart
similarity index 52%
copy from runtime/third_party/double-conversion/src/diy-fp.cc
copy to tests/corelib/regexp/capture_test.dart
index ddd1891b168ada0b67b3d124ff3c63b352d7fda6..fa7391a9ee4e91bef140930205da3c2d6f10ab14 100644
--- a/runtime/third_party/double-conversion/src/diy-fp.cc
+++ b/tests/corelib/regexp/capture_test.dart
@@ -1,4 +1,5 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
+// Copyright (c) 2014, the Dart project authors. All rights reserved.
+// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,33 +26,28 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import 'v8_regexp_utils.dart';
+import 'package:expect/expect.dart';
-#include "diy-fp.h"
-#include "utils.h"
+void main() {
+ // Tests from http://blog.stevenlevithan.com/archives/npcg-javascript
-namespace double_conversion {
+ assertEquals(true, new RegExp(r"(x)?\1y").hasMatch("y"));
+ shouldBe(new RegExp(r"(x)?\1y").firstMatch("y"), ["y", null]);
+ shouldBe(new RegExp(r"(x)?y").firstMatch("y"), ["y", null]);
+ shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]);
+ shouldBe(firstMatch("y", new RegExp(r"(x)?y")), ["y", null]);
+ shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]);
+ Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?\1y")));
+ Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?y")));
+ assertEquals(0, "y".indexOf(new RegExp(r"(x)?\1y")));
+ assertEquals("z", "y".replaceAll(new RegExp(r"(x)?\1y"), "z"));
-void DiyFp::Multiply(const DiyFp& other) {
- // Simply "emulates" a 128 bit multiplication.
- // However: the resulting number only contains 64 bits. The least
- // significant 64 bits are only used for rounding the most significant 64
- // bits.
- const uint64_t kM32 = 0xFFFFFFFFU;
- uint64_t a = f_ >> 32;
- uint64_t b = f_ & kM32;
- uint64_t c = other.f_ >> 32;
- uint64_t d = other.f_ & kM32;
- uint64_t ac = a * c;
- uint64_t bc = b * c;
- uint64_t ad = a * d;
- uint64_t bd = b * d;
- uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
- // By adding 1U << 31 to tmp we round the final result.
- // Halfway cases will be round up.
- tmp += 1U << 31;
- uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
- e_ += other.e_ + 64;
- f_ = result_f;
-}
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=476146
+ shouldBe(new RegExp(r"^(b+|a){1,2}?bc").firstMatch("bbc"), ["bbc", "b"]);
+ shouldBe(new RegExp(r"((\3|b)\2(a)){2,}").firstMatch("bbaababbabaaaaabbaaaabba"),
+ ["bbaa", "a", "", "a"]);
-} // namespace double_conversion
+ // From crbug.com/128821 - don't hang:
+ firstMatch("", new RegExp(r"((a|i|A|I|u|o|U|O)(s|c|b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z|B|C|D|F|G|H|J|K|L|M|N|P|Q|R|S|T|V|W|X|Y|Z)*) de\/da([.,!?\s]|$)"));
+}
« no previous file with comments | « tests/corelib/regexp/capture-3_test.dart ('k') | tests/corelib/regexp/captures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698