| OLD | NEW |
| 1 #library('TestUtils'); | 1 #library('TestUtils'); |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * Verifies that [actual] has the same graph structure as [expected]. | 4 * Verifies that [actual] has the same graph structure as [expected]. |
| 5 * Detects cycles and DAG structure in Maps and Lists. | 5 * Detects cycles and DAG structure in Maps and Lists. |
| 6 */ | 6 */ |
| 7 verifyGraph(expected, actual) { | 7 verifyGraph(expected, actual) { |
| 8 var eItems = []; | 8 var eItems = []; |
| 9 var aItems = []; | 9 var aItems = []; |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Expect.equals(expected.length, actual.length, | 41 Expect.equals(expected.length, actual.length, |
| 42 message(path, 'different list lengths')); | 42 message(path, 'different list lengths')); |
| 43 for (var i = 0; i < expected.length; i++) { | 43 for (var i = 0; i < expected.length; i++) { |
| 44 walk('$path[$i]', expected[i], actual[i]); | 44 walk('$path[$i]', expected[i], actual[i]); |
| 45 } | 45 } |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 | 48 |
| 49 if (expected is Map) { | 49 if (expected is Map) { |
| 50 Expect.isTrue(actual is Map, message(path, '$actual is Map')); | 50 Expect.isTrue(actual is Map, message(path, '$actual is Map')); |
| 51 for (var key in expected.getKeys()) { | 51 for (var key in expected.keys) { |
| 52 if (!actual.containsKey(key)) { | 52 if (!actual.containsKey(key)) { |
| 53 Expect.fail(message(path, 'missing key "$key"')); | 53 Expect.fail(message(path, 'missing key "$key"')); |
| 54 } | 54 } |
| 55 walk('$path["$key"]', expected[key], actual[key]); | 55 walk('$path["$key"]', expected[key], actual[key]); |
| 56 } | 56 } |
| 57 for (var key in actual.getKeys()) { | 57 for (var key in actual.keys) { |
| 58 if (!expected.containsKey(key)) { | 58 if (!expected.containsKey(key)) { |
| 59 Expect.fail(message(path, 'extra key "$key"')); | 59 Expect.fail(message(path, 'extra key "$key"')); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 Expect.fail('Unhandled type: $expected'); | 65 Expect.fail('Unhandled type: $expected'); |
| 66 } | 66 } |
| 67 | 67 |
| 68 walk('', expected, actual); | 68 walk('', expected, actual); |
| 69 } | 69 } |
| OLD | NEW |