Chromium Code Reviews| OLD | NEW |
|---|---|
| (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. | |
| 6 | |
|
Lasse Reichstein Nielsen
2014/10/23 13:21:58
Could you rename this to, e.g., "v8_regexp_helper.
zerny-google
2014/10/24 12:38:37
Done.
| |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 void assertEquals(actual, expected, [message]) => | |
|
Lasse Reichstein Nielsen
2014/10/23 13:21:58
Please don't use => for void methods. Just { ... }
zerny-google
2014/10/24 12:38:37
Done.
| |
| 10 Expect.equals(actual, expected, message); | |
| 11 void assertTrue(actual, [message]) => Expect.isTrue(actual, message); | |
| 12 void assertFalse(actual, [message]) => Expect.isFalse(actual, message); | |
| 13 void assertThrows(fn, [testid]) => Expect.throws(fn); | |
|
Lasse Reichstein Nielsen
2014/10/23 13:21:57
=> Expect.throws(fn, null, testid);
Might as well
zerny-google
2014/10/24 12:38:37
Done.
| |
| 14 void assertNull(actual, [testid]) => Expect.isNull(actual); | |
|
Lasse Reichstein Nielsen
2014/10/23 13:21:58
Ditto.
zerny-google
2014/10/24 12:38:37
Done.
| |
| 15 | |
| 16 void assertToStringEquals(str, match, testid) { | |
| 17 var actual = []; | |
| 18 for (int i = 0; i <= match.groupCount; i++) { | |
| 19 actual.add(match.group(i)); | |
| 20 } | |
| 21 | |
| 22 Expect.equals(str, | |
| 23 actual.map((s) => (s == null) ? "" : s).join(","), | |
| 24 "Test $testid failed"); | |
| 25 } | |
| 26 | |
| 27 void shouldBeTrue(actual) => Expect.isTrue(actual); | |
| 28 void shouldBeFalse(actual) => Expect.isFalse(actual); | |
| 29 void shouldBeNull(actual) => Expect.isNull(actual); | |
| 30 | |
| 31 void shouldBe(actual, expected, [message]) { | |
| 32 if (expected == null) { | |
| 33 Expect.isNull(actual); | |
| 34 } else { | |
| 35 Expect.equals(expected.length, actual.groupCount + 1); | |
| 36 for (int i = 0; i <= actual.groupCount; i++) { | |
| 37 Expect.equals(expected[i], actual.group(i)); | |
| 38 } | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 Match firstMatch(String str, RegExp pattern) => pattern.firstMatch(str); | |
| 43 List<String> allStringMatches(String str, RegExp pattern) => | |
| 44 pattern.allMatches(str).map((Match m) => m.group(0)).toList(); | |
| 45 | |
| 46 void description(str) { } | |
| OLD | NEW |