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

Unified Diff: tests/language/regex/alternatives_test.dart

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed Ivan's comments. 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
Index: tests/language/regex/alternatives_test.dart
diff --git a/tests/language/regex/alternatives_test.dart b/tests/language/regex/alternatives_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..866d98a204dc99ef5a6780dfa5f665117d09b1aa
--- /dev/null
+++ b/tests/language/regex/alternatives_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2014, 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.
+
+import 'util.dart';
+import 'package:expect/expect.dart';
+
+void main() {
+ description(
+ 'Test regular expression processing with alternatives.'
+ );
+
+ var s1 = "<p>content</p>";
+ shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))")), ["<p>","p>",null,null,"p>","p"]);
+ shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))")), ["<p>","p>",null,null,null,"p>","p"]);
+ shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|.+?)>")), ["<p>","p"]);
+
+ // Force YARR to use Interpreter by using iterative parentheses
+ shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|((([^>])+)>))")), ["<p>","p>",null,null,"p>","p","p"]);
+ shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|((([^>])+)>))")), ["<p>","p>",null,null,null,"p>","p","p"]);
+ shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|(.)+?)>")), ["<p>","p","p"]);
+
+ // Force YARR to use Interpreter by using backreference
+ var s2 = "<p>p</p>";
+ shouldBe(firstMatch(s2, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))\5")), ["<p>p","p>",null,null,"p>","p"]);
+ shouldBe(firstMatch(s2, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))\6")), ["<p>p","p>",null,null,null,"p>","p"]);
+ shouldBe(firstMatch(s2, new RegExp(r"<(a|\\/p|.+?)>\1")), ["<p>p","p"]);
+}
« no previous file with comments | « tests/language/regex/alternative-length-miscalculation_test.dart ('k') | tests/language/regex/ascii-regexp-subject_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698