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

Side by Side Diff: tests/corelib/regexp/v8_regexp_utils.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: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Utility functions to easy porting of V8 tests.
Lasse Reichstein Nielsen 2014/10/29 11:25:31 to->for (or, avoiding passive tense, "to easily po
zerny-google 2014/10/30 11:31:28 Done.
6
7 import "package:expect/expect.dart";
8
9 void assertEquals(actual, expected, [String message = null]) {
10 Expect.equals(actual, expected, message);
11 }
12 void assertTrue(actual, [String message = null]) { Expect.isTrue(actual, message ); }
13 void assertFalse(actual, [String message = null]) { Expect.isFalse(actual, messa ge); }
14 void assertThrows(fn, [num testid = null]) {
15 Expect.throws(fn, null, "Test $testid failed");
Lasse Reichstein Nielsen 2014/10/29 11:25:31 Don't need to say "failed" here, this message is o
zerny-google 2014/10/30 11:31:28 Done.
16 }
17 void assertNull(actual, [num testid = null]) {
18 Expect.isNull(actual, "Test $testid failed");
19 }
20
21 void assertToStringEquals(str, match, num testid) {
22 var actual = [];
23 for (int i = 0; i <= match.groupCount; i++) {
24 actual.add(match.group(i));
Lasse Reichstein Nielsen 2014/10/29 11:25:31 You can convert null to "" here, and avoid the "ma
zerny-google 2014/10/30 11:31:28 Done.
25 }
26
27 Expect.equals(str,
28 actual.map((s) => (s == null) ? "" : s).join(","),
29 "Test $testid failed");
30 }
31
32 void shouldBeTrue(actual) { Expect.isTrue(actual); }
33 void shouldBeFalse(actual) { Expect.isFalse(actual); }
34 void shouldBeNull(actual) { Expect.isNull(actual); }
35
36 void shouldBe(actual, expected, [String message = null]) {
37 if (expected == null) {
38 Expect.isNull(actual, message);
39 } else {
40 Expect.equals(expected.length, actual.groupCount + 1);
41 for (int i = 0; i <= actual.groupCount; i++) {
42 Expect.equals(expected[i], actual.group(i), message);
43 }
44 }
45 }
46
47 Match firstMatch(String str, RegExp pattern) => pattern.firstMatch(str);
48 List<String> allStringMatches(String str, RegExp pattern) =>
49 pattern.allMatches(str).map((Match m) => m.group(0)).toList();
50
51 void description(str) { }
OLDNEW
« no previous file with comments | « tests/corelib/regexp/unicodeCaseInsensitive_test.dart ('k') | tests/corelib/regexp/zero-length-alternatives_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698