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 easily port V8 tests. |
| 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"); |
| 16 } |
| 17 void assertNull(actual, [num testid = null]) { |
| 18 Expect.isNull(actual, "Test $testid"); |
| 19 } |
| 20 |
| 21 void assertToStringEquals(str, match, num testid) { |
| 22 var actual = []; |
| 23 for (int i = 0; i <= match.groupCount; i++) { |
| 24 var g = match.group(i); |
| 25 actual.add((g == null) ? "" : g); |
| 26 } |
| 27 Expect.equals(str, actual.join(","), "Test $testid"); |
| 28 } |
| 29 |
| 30 void shouldBeTrue(actual) { Expect.isTrue(actual); } |
| 31 void shouldBeFalse(actual) { Expect.isFalse(actual); } |
| 32 void shouldBeNull(actual) { Expect.isNull(actual); } |
| 33 |
| 34 void shouldBe(actual, expected, [String message = null]) { |
| 35 if (expected == null) { |
| 36 Expect.isNull(actual, message); |
| 37 } else { |
| 38 Expect.equals(expected.length, actual.groupCount + 1); |
| 39 for (int i = 0; i <= actual.groupCount; i++) { |
| 40 Expect.equals(expected[i], actual.group(i), message); |
| 41 } |
| 42 } |
| 43 } |
| 44 |
| 45 Match firstMatch(String str, RegExp pattern) => pattern.firstMatch(str); |
| 46 List<String> allStringMatches(String str, RegExp pattern) => |
| 47 pattern.allMatches(str).map((Match m) => m.group(0)).toList(); |
| 48 |
| 49 void description(str) { } |
OLD | NEW |