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

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

Issue 667043003: Port regexp tests from V8 to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/corelib/regexp/dotstar_test.dart
diff --git a/tests/corelib/regexp/dotstar_test.dart b/tests/corelib/regexp/dotstar_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7d32c921eae503296e26c52451353bedde87aa0b
--- /dev/null
+++ b/tests/corelib/regexp/dotstar_test.dart
@@ -0,0 +1,145 @@
+// 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("This page tests handling of parentheses subexpressions.");
+
+ var regexp1 = new RegExp(r".*blah.*");
+ shouldBeNull(regexp1.firstMatch('test'));
+ shouldBe(regexp1.firstMatch('blah'), ['blah']);
+ shouldBe(regexp1.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp1.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp1.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp1.firstMatch('blah\nsecond'), ['blah']);
+ shouldBe(regexp1.firstMatch('first\nblah'), ['blah']);
+ shouldBe(regexp1.firstMatch('first\nblah\nthird'), ['blah']);
+ shouldBe(regexp1.firstMatch('first\nblah2\nblah3'), ['blah2']);
+
+ var regexp2 = new RegExp(r"^.*blah.*");
+ shouldBeNull(regexp2.firstMatch('test'));
+ shouldBe(regexp2.firstMatch('blah'), ['blah']);
+ shouldBe(regexp2.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp2.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp2.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp2.firstMatch('blah\nsecond'), ['blah']);
+ shouldBeNull(regexp2.firstMatch('first\nblah'));
+ shouldBeNull(regexp2.firstMatch('first\nblah\nthird'));
+ shouldBeNull(regexp2.firstMatch('first\nblah2\nblah3'));
+
+ var regexp3 = new RegExp(r".*blah.*$");
+ shouldBeNull(regexp3.firstMatch('test'));
+ shouldBe(regexp3.firstMatch('blah'), ['blah']);
+ shouldBe(regexp3.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp3.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp3.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBeNull(regexp3.firstMatch('blah\nsecond'));
+ shouldBe(regexp3.firstMatch('first\nblah'), ['blah']);
+ shouldBeNull(regexp3.firstMatch('first\nblah\nthird'));
+ shouldBe(regexp3.firstMatch('first\nblah2\nblah3'), ['blah3']);
+
+ var regexp4 = new RegExp(r"^.*blah.*$");
+ shouldBeNull(regexp4.firstMatch('test'));
+ shouldBe(regexp4.firstMatch('blah'), ['blah']);
+ shouldBe(regexp4.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp4.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp4.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBeNull(regexp4.firstMatch('blah\nsecond'));
+ shouldBeNull(regexp4.firstMatch('first\nblah'));
+ shouldBeNull(regexp4.firstMatch('first\nblah\nthird'));
+ shouldBeNull(regexp4.firstMatch('first\nblah2\nblah3'));
+
+ var regexp5 = new RegExp(r".*?blah.*");
+ shouldBeNull(regexp5.firstMatch('test'));
+ shouldBe(regexp5.firstMatch('blah'), ['blah']);
+ shouldBe(regexp5.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp5.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp5.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp5.firstMatch('blah\nsecond'), ['blah']);
+ shouldBe(regexp5.firstMatch('first\nblah'), ['blah']);
+ shouldBe(regexp5.firstMatch('first\nblah\nthird'), ['blah']);
+ shouldBe(regexp5.firstMatch('first\nblah2\nblah3'), ['blah2']);
+
+ var regexp6 = new RegExp(r".*blah.*?");
+ shouldBeNull(regexp6.firstMatch('test'));
+ shouldBe(regexp6.firstMatch('blah'), ['blah']);
+ shouldBe(regexp6.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp6.firstMatch('blah1'), ['blah']);
+ shouldBe(regexp6.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp6.firstMatch('blah\nsecond'), ['blah']);
+ shouldBe(regexp6.firstMatch('first\nblah'), ['blah']);
+ shouldBe(regexp6.firstMatch('first\nblah\nthird'), ['blah']);
+ shouldBe(regexp6.firstMatch('first\nblah2\nblah3'), ['blah']);
+
+ var regexp7 = new RegExp(r"^.*?blah.*?$");
+ shouldBeNull(regexp7.firstMatch('test'));
+ shouldBe(regexp7.firstMatch('blah'), ['blah']);
+ shouldBe(regexp7.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp7.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp7.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBeNull(regexp7.firstMatch('blah\nsecond'));
+ shouldBeNull(regexp7.firstMatch('first\nblah'));
+ shouldBeNull(regexp7.firstMatch('first\nblah\nthird'));
+ shouldBeNull(regexp7.firstMatch('first\nblah2\nblah3'));
+
+ var regexp8 = new RegExp(r"^(.*)blah.*$");
+ shouldBeNull(regexp8.firstMatch('test'));
+ shouldBe(regexp8.firstMatch('blah'), ['blah','']);
+ shouldBe(regexp8.firstMatch('1blah'), ['1blah','1']);
+ shouldBe(regexp8.firstMatch('blah1'), ['blah1','']);
+ shouldBe(regexp8.firstMatch('blah blah blah'), ['blah blah blah','blah blah ']);
+ shouldBeNull(regexp8.firstMatch('blah\nsecond'));
+ shouldBeNull(regexp8.firstMatch('first\nblah'));
+ shouldBeNull(regexp8.firstMatch('first\nblah\nthird'));
+ shouldBeNull(regexp8.firstMatch('first\nblah2\nblah3'));
+
+ var regexp9 = new RegExp(r".*blah.*", multiLine: true);
+ shouldBeNull(regexp9.firstMatch('test'));
+ shouldBe(regexp9.firstMatch('blah'), ['blah']);
+ shouldBe(regexp9.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp9.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp9.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp9.firstMatch('blah\nsecond'), ['blah']);
+ shouldBe(regexp9.firstMatch('first\nblah'), ['blah']);
+ shouldBe(regexp9.firstMatch('first\nblah\nthird'), ['blah']);
+ shouldBe(regexp9.firstMatch('first\nblah2\nblah3'), ['blah2']);
+
+ var regexp10 = new RegExp(r"^.*blah.*", multiLine: true);
+ shouldBeNull(regexp10.firstMatch('test'));
+ shouldBe(regexp10.firstMatch('blah'), ['blah']);
+ shouldBe(regexp10.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp10.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp10.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBe(regexp10.firstMatch('blah\nsecond'), ['blah']);
+ shouldBe(regexp10.firstMatch('first\nblah'), ['blah']);
+ shouldBe(regexp10.firstMatch('first\nblah\nthird'), ['blah']);
+ shouldBe(regexp10.firstMatch('first\nblah2\nblah3'), ['blah2']);
+
+ var regexp11 = new RegExp(r".*(?:blah).*$");
+ shouldBeNull(regexp11.firstMatch('test'));
+ shouldBe(regexp11.firstMatch('blah'), ['blah']);
+ shouldBe(regexp11.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp11.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp11.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBeNull(regexp11.firstMatch('blah\nsecond'));
+ shouldBe(regexp11.firstMatch('first\nblah'), ['blah']);
+ shouldBeNull(regexp11.firstMatch('first\nblah\nthird'));
+ shouldBe(regexp11.firstMatch('first\nblah2\nblah3'), ['blah3']);
+
+ var regexp12 = new RegExp(r".*(?:blah|buzz|bang).*$");
+ shouldBeNull(regexp12.firstMatch('test'));
+ shouldBe(regexp12.firstMatch('blah'), ['blah']);
+ shouldBe(regexp12.firstMatch('1blah'), ['1blah']);
+ shouldBe(regexp12.firstMatch('blah1'), ['blah1']);
+ shouldBe(regexp12.firstMatch('blah blah blah'), ['blah blah blah']);
+ shouldBeNull(regexp12.firstMatch('blah\nsecond'));
+ shouldBe(regexp12.firstMatch('first\nblah'), ['blah']);
+ shouldBeNull(regexp12.firstMatch('first\nblah\nthird'));
+ shouldBe(regexp12.firstMatch('first\nblah2\nblah3'), ['blah3']);
+
+ var regexp13 = new RegExp(r".*\n\d+.*");
+ shouldBe(regexp13.firstMatch('abc\n123'), ['abc\n123']);
+}

Powered by Google App Engine
This is Rietveld 408576698