Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: packages/quiver/lib/testing/src/equality/equality.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: packages/quiver/lib/testing/src/equality/equality.dart
diff --git a/packages/quiver/lib/testing/src/equality/equality.dart b/packages/quiver/lib/testing/src/equality/equality.dart
index 2053e57db190c6d4bb02cc6e0f2aac93f9937e91..e67222ab1c524b0f21c19c2287ef3b6ec4a580e9 100644
--- a/packages/quiver/lib/testing/src/equality/equality.dart
+++ b/packages/quiver/lib/testing/src/equality/equality.dart
@@ -14,43 +14,40 @@
part of quiver.testing.equality;
-/**
- * Matcher for == and hashCode methods of a class.
- *
- * To use, invoke areEqualityGroups with a list of equality groups where each
- * group contains objects that are supposed to be equal to each other, and
- * objects of different groups are expected to be unequal. For example:
- *
- * expect({
- * 'hello': ["hello", "h" + "ello"],
- * 'world': ["world", "wor" + "ld"],
- * 'three': [2, 1 + 1]
- * }, areEqualityGroups);
- *
- * This tests that:
- *
- * * comparing each object against itself returns true
- * * comparing each object against an instance of an incompatible class
- * returns false
- * * comparing each pair of objects within the same equality group returns
- * true
- * * comparing each pair of objects from different equality groups returns
- * false
- * * the hash codes of any two equal objects are equal
- * * equals implementation is idempotent
- *
- * The format of the Map passed to expect is such that the map keys are used in
- * error messages to identify the group described by the map value.
- *
- * When a test fails, the error message labels the objects involved in
- * the failed comparison as follows:
- *
- * "`[group x, item j]`" refers to the ith item in the xth equality group,
- * where both equality groups and the items within equality groups are
- * numbered starting from 1. When either a constructor argument or an
- * equal object is provided, that becomes group 1.
- *
- */
+/// Matcher for == and hashCode methods of a class.
+///
+/// To use, invoke areEqualityGroups with a list of equality groups where each
+/// group contains objects that are supposed to be equal to each other, and
+/// objects of different groups are expected to be unequal. For example:
+///
+/// expect({
+/// 'hello': ["hello", "h" + "ello"],
+/// 'world': ["world", "wor" + "ld"],
+/// 'three': [2, 1 + 1]
+/// }, areEqualityGroups);
+///
+/// This tests that:
+///
+/// * comparing each object against itself returns true
+/// * comparing each object against an instance of an incompatible class
+/// returns false
+/// * comparing each pair of objects within the same equality group returns
+/// true
+/// * comparing each pair of objects from different equality groups returns
+/// false
+/// * the hash codes of any two equal objects are equal
+/// * equals implementation is idempotent
+///
+/// The format of the Map passed to expect is such that the map keys are used in
+/// error messages to identify the group described by the map value.
+///
+/// When a test fails, the error message labels the objects involved in
+/// the failed comparison as follows:
+///
+/// "`[group x, item j]`" refers to the ith item in the xth equality group,
+/// where both equality groups and the items within equality groups are
+/// numbered starting from 1. When either a constructor argument or an
+/// equal object is provided, that becomes group 1.
const Matcher areEqualityGroups = const _EqualityGroupMatcher();
const _repetitions = 3;
@@ -64,9 +61,9 @@ class _EqualityGroupMatcher extends Matcher {
description.add('to be equality groups');
@override
- bool matches(Map<String, List> item, Map matchState) {
+ bool matches(item, Map matchState) {
try {
- _verifyEqualityGroups(item, matchState);
+ _verifyEqualityGroups(item as Map<String, List>, matchState);
return true;
} on MatchError catch (e) {
matchState[failureReason] = e.toString();
@@ -82,7 +79,7 @@ class _EqualityGroupMatcher extends Matcher {
if (equalityGroups == null) {
throw new MatchError('Equality Group must not be null');
}
- var equalityGroupsCopy = {};
+ final equalityGroupsCopy = <String, List>{};
equalityGroups.forEach((String groupName, List group) {
if (groupName == null) {
throw new MatchError('Group name must not be null');
@@ -94,7 +91,7 @@ class _EqualityGroupMatcher extends Matcher {
});
// Run the test multiple times to ensure deterministic equals
- for (var run in range(_repetitions)) {
+ for (var i = 0; i < _repetitions; i++) {
_checkBasicIdentity(equalityGroupsCopy, matchState);
_checkGroupBasedEquality(equalityGroupsCopy);
}
« no previous file with comments | « packages/quiver/lib/testing/src/async/fake_async.dart ('k') | packages/quiver/lib/testing/src/runtime/checked_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698