Index: tests/html/utils.dart |
=================================================================== |
--- tests/html/utils.dart (revision 14114) |
+++ tests/html/utils.dart (working copy) |
@@ -1,4 +1,5 @@ |
#library('TestUtils'); |
+#import('../../pkg/unittest/unittest.dart'); |
/** |
* Verifies that [actual] has the same graph structure as [expected]. |
@@ -7,6 +8,8 @@ |
verifyGraph(expected, actual) { |
var eItems = []; |
var aItems = []; |
+ var isMap = new isInstanceOf<Map>('Map'); |
+ var isList = new isInstanceOf<List>('List'); |
message(path, reason) => path == '' |
? reason |
@@ -14,22 +17,22 @@ |
walk(path, expected, actual) { |
if (expected is String || expected is num || expected == null) { |
- Expect.equals(expected, actual, message(path, 'not equal')); |
+ expect(actual, equals(expected), reason: message(path, 'not equal')); |
return; |
} |
// Cycle or DAG? |
for (int i = 0; i < eItems.length; i++) { |
if (expected === eItems[i]) { |
- Expect.identical(aItems[i], actual, |
- message(path, 'missing back or side edge')); |
+ expect(actual, same(aItems[i]), |
+ reason: message(path, 'missing back or side edge')); |
return; |
} |
} |
for (int i = 0; i < aItems.length; i++) { |
if (actual === aItems[i]) { |
- Expect.identical(eItems[i], expected, |
- message(path, 'extra back or side edge')); |
+ expect(expected, same(eItems[i]), |
+ reason: message(path, 'extra back or side edge')); |
return; |
} |
} |
@@ -37,9 +40,9 @@ |
aItems.add(actual); |
if (expected is List) { |
- Expect.isTrue(actual is List, message(path, '$actual is List')); |
- Expect.equals(expected.length, actual.length, |
- message(path, 'different list lengths')); |
+ expect(actual, isList, reason: message(path, '$actual is List')); |
+ expect(actual.length, expected.length, |
+ reason: message(path, 'different list lengths')); |
for (var i = 0; i < expected.length; i++) { |
walk('$path[$i]', expected[i], actual[i]); |
} |
@@ -47,22 +50,22 @@ |
} |
if (expected is Map) { |
- Expect.isTrue(actual is Map, message(path, '$actual is Map')); |
+ expect(actual, isMap, reason: message(path, '$actual is Map')); |
for (var key in expected.keys) { |
if (!actual.containsKey(key)) { |
- Expect.fail(message(path, 'missing key "$key"')); |
+ expect(false, isTrue, reason: message(path, 'missing key "$key"')); |
} |
walk('$path["$key"]', expected[key], actual[key]); |
} |
for (var key in actual.keys) { |
if (!expected.containsKey(key)) { |
- Expect.fail(message(path, 'extra key "$key"')); |
+ expect(false, isTrue, reason: message(path, 'extra key "$key"')); |
} |
} |
return; |
} |
- Expect.fail('Unhandled type: $expected'); |
+ expect(false, isTrue, reason: 'Unhandled type: $expected'); |
} |
walk('', expected, actual); |