Migrate Color.toString() test, improves equalsIgnoringHashCodes (#154934)

This migrates the last failing test for https://github.com/flutter/engine/pull/54981.  In order to effectively resolve that test I had to make `equalsIgnoringHashCodes` more usable by printing out the line that differs instead of just a huge blob of "expected" vs "actual.

## example
Here's the output after the change.

### test
```
  test('equalsIgnoringHashCodes - wrong line', () {
    expect(
      '1\n2\n3\n4\n5\n6\n7\n8\n9\n10',
      equalsIgnoringHashCodes('1\n2\n3\n4\n5\n6\na\n8\n9\n10'),
    );
  });
```
### output
```
Expected: normalized value matches
          '1\n'
            '2\n'
            '3\n'
            '4\n'
            '5\n'
            '6\n'
            'a\n'
            '8\n'
            '9\n'
            '10'
  Actual: '1\n'
            '2\n'
            '3\n'
            '4\n'
            '5\n'
            '6\n'
            '7\n'
            '8\n'
            '9\n'
            '10'
   Which: Lines 7 differed, expected: 
          'a'
          but got
          '7'
```
This commit is contained in:
gaaclarke
2024-09-11 10:34:58 -07:00
committed by GitHub
parent bcf1c5a243
commit b5ce70a760
3 changed files with 83 additions and 91 deletions

View File

@@ -194,6 +194,26 @@ void main() {
);
});
test('equalsIgnoringHashCodes - wrong line', () {
TestFailure? failure;
try {
expect(
'1\n2\n3\n4\n5\n6\n7\n8\n9\n10',
equalsIgnoringHashCodes('1\n2\n3\n4\n5\n6\na\n8\n9\n10'),
);
} on TestFailure catch (e) {
failure = e;
}
expect(failure, isNotNull);
if (failure != null) {
final String? message = failure.message;
expect(message, contains('Lines 7 differed'));
expect(message, contains("'a'"));
expect(message, contains("'7'"));
}
});
test('moreOrLessEquals', () {
expect(0.0, moreOrLessEquals(1e-11));
expect(1e-11, moreOrLessEquals(0.0));