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"]); |
+} |