Index: packages/path/test/utils.dart |
diff --git a/packages/path/test/utils.dart b/packages/path/test/utils.dart |
index 7d917a0be99fccad9fd9edb16aca73e5fbd47b34..5e22ce1f31777b69338df23d781967d3b5f7bc62 100644 |
--- a/packages/path/test/utils.dart |
+++ b/packages/path/test/utils.dart |
@@ -2,10 +2,31 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library path.test.utils; |
- |
import "package:test/test.dart"; |
-import "package:path/path.dart" as path; |
+import "package:path/path.dart" as p; |
/// A matcher for a closure that throws a [path.PathException]. |
-final throwsPathException = throwsA(new isInstanceOf<path.PathException>()); |
+final throwsPathException = throwsA(new isInstanceOf<p.PathException>()); |
+ |
+void expectEquals(p.Context context, String path1, String path2) { |
+ expect(context.equals(path1, path2), isTrue, |
+ reason: 'Expected "$path1" to equal "$path2".'); |
+ expect(context.equals(path2, path1), isTrue, |
+ reason: 'Expected "$path2" to equal "$path1".'); |
+ expect(context.hash(path1), equals(context.hash(path2)), |
+ reason: 'Expected "$path1" to hash the same as "$path2".'); |
+} |
+ |
+void expectNotEquals(p.Context context, String path1, String path2, |
+ {bool allowSameHash: false}) { |
+ expect(context.equals(path1, path2), isFalse, |
+ reason: 'Expected "$path1" not to equal "$path2".'); |
+ expect(context.equals(path2, path1), isFalse, |
+ reason: 'Expected "$path2" not to equal "$path1".'); |
+ |
+ // Hash collisions are allowed, but the test author should be explicitly aware |
+ // when they occur. |
+ if (allowSameHash) return; |
+ expect(context.hash(path1), isNot(equals(context.hash(path2))), |
+ reason: 'Expected "$path1" not to hash the same as "$path2".'); |
+} |