-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unittest.dart does not compare lists correctly #3274
Comments
Added Area-UnitTest, Triaged labels. |
This comment was originally written by reng...@gmail.com Similarly expect([[]]).equals([[]]); and expect([{}]).equals([{}]); are failing. In the context of tests I would expect that the same comparator also goes into nested literals. |
This comment was originally written by reng...@gmail.com I think this issue can be closed. The reported problem is no longer an issue with the new matchers: expect([[]], recursivelyMatches([[]])); expect([{}], recursivelyMatches([{}])); |
Agree with previous comment, and note that the next SDK push will remove recursivelyMatches; you can just use equals: void main() { |
That said, perhaps someone should take a look at the original issue; that version of Expect is still used for core language tests. Removed Area-UnitTest label. |
Added Fixed label. |
Revisions updated by `dart tools/rev_sdk_deps.dart`. browser_launcher (https://github.com/dart-lang/browser_launcher/compare/5fa0bd6..2712dda): 2712dda 2022-12-13 Anna Gringauze Fix internal CI test failures (#35) dartdoc (https://github.com/dart-lang/dartdoc/compare/eb90a44..1f42216): 1f422163 2022-12-13 Sam Rawlins Bump to 6.1.5 (#3274) intl (https://github.com/dart-lang/intl/compare/234b291..6fb07f2): 6fb07f2 2022-12-14 Copybara-Service Merge pull request #520 from dart-lang:revto18 1f9815c 2022-12-14 Moritz Rev version in preparation for publish of 0.18.0 1d37c42 2022-12-13 Googler Internal change 708b85c 2022-12-13 Copybara-Service Merge pull request #498 from dart-lang:remove_intl_stream 2d9eca9 2022-09-28 moritz sort imports 08a35bd 2022-09-28 moritz Merge branch 'master' into remove_intl_stream 0fc6ab9 2022-09-28 moritz Changes as per review 4680742 2022-09-27 moritz rename to stack f687c72 2022-09-27 moritz changes as per review ef36013 2022-09-26 moritz add reference to benchmark 117c0cf 2022-09-26 moritz separate read and pop 434378a 2022-09-26 moritz move method e98c4aa 2022-09-26 moritz fix typo 9234540 2022-09-26 moritz rename file 024cffc 2022-09-26 moritz make it a tad faster c6f7b6a 2022-09-26 moritz some renaming 443c9e0 2022-09-26 moritz Remove StringIterator 1953002 2022-09-23 Nate Bosch Inline the extension 4dfdc1b 2022-09-22 Nate Bosch Simplify the IntlStream class mime (https://github.com/dart-lang/mime/compare/c0c4c47..273d454): 273d454 2022-12-13 tomk9 Add .dcm to extension map (#74) aacec32 2022-12-12 Kevin Moore Update to latest lints, bump min SDK to 2.18 (#77) 536db4f 2022-12-12 Kevin Moore blast_repo fixes (#79) 2343229 2022-12-12 Kevin Moore Add .msj (and change .js) to text/javascript (#76) mockito (https://github.com/dart-lang/mockito/compare/347d3e4..942dd03): 942dd03 2022-12-12 yanok Override `SmartFake.toString` to be super-verbose 5f97a43 2022-12-09 Sam Rawlins Stop using deprecated analyzer APIs 0660e61 2022-12-06 yanok Generate method overrides even then source lib is not null-safe cf7d851 2022-12-06 yanok Add override for `Object.operator==` in `SmartFake` 6b89e99 2022-12-02 yanok Automated g4 rollback of changelist 492410078. d11d010 2022-12-02 yanok Generate method overrides even then source lib is not null-safe sse (https://github.com/dart-lang/sse/compare/d396145..cfa93b1): cfa93b1 2022-12-14 Elliott Brooks (she/her) Add `package:js` to dependencies (#71) 00335e4 2022-12-13 Elliott Brooks (she/her) Update `package:sse` to `4.1.2`(#70) webdev (https://github.com/dart-lang/webdev/compare/3e2364e..317288a): 317288a 2022-12-14 Derek Xu Remove ChromeProxyService.setExceptionPauseMode() (#1820) bbe7143 2022-12-14 Elliott Brooks (she/her) Migrate `events_test.dart` to null-safety (#1819) 1d1c98f 2022-12-14 Elliott Brooks (she/her) Settings page, Dart Debugger panel, and Flutter Inspector panel match DevTools styles (#1815) a9b8887 2022-12-13 Elliott Brooks (she/her) Update tests that are incompatible with `3.0.0` (#1817) Change-Id: I08e555dc22e5577740fe43e91ff31e4601ac15f0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275781 Commit-Queue: Nate Bosch <nbosch@google.com> Auto-Submit: Devon Carew <devoncarew@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
This is an accumulation of 12 commits to dartdoc, imported into dart-lang/sdk across 4 commits, noted below. I've also stripped out the changes made to any other repository in this DEPS file. Revisions updated by `dart tools/rev_sdk_deps.dart`. From cabf333: dartdoc (https://github.com/dart-lang/dartdoc/compare/eb90a44..1f42216): 1f422163 2022-12-13 Sam Rawlins Bump to 6.1.5 (#3274) From a3b7a76: eb90a44c 2022-12-12 Sam Rawlins Remove annotations from the features section of each element (#3268) 16126376 2022-12-12 Parker Lougheed Don't show null in search results when no description (#3273) 3ff7aa75 2022-12-12 Sam Rawlins Fix search arrows by using a flat list of suggestions (#3271) 90264fb4 2022-12-12 dependabot[bot] Bump github/codeql-action from 2.1.35 to 2.1.36 (#3270) bede500d 2022-12-12 Sam Rawlins Fix remote linking in 2.18 and 3.0.0 (#3267) From 0c14719: dartdoc (https://github.com/dart-lang/dartdoc/compare/4d7dc93..f2bb6e9): f2bb6e92 2022-12-07 Sam Rawlins Bump to 6.1.4 (#3266) From 3a1d7c7: dartdoc (https://github.com/dart-lang/dartdoc/compare/dc502d0..4d7dc93): 4d7dc93b 2022-12-05 dependabot[bot] Bump github/codeql-action from 2.1.31 to 2.1.35 (#3263) bcf8b6e8 2022-12-05 Parker Lougheed Weight enums the same as classes for searching (#3260) 7d95578b 2022-12-04 Parker Lougheed Update template descriptions (#3258) d558f043 2022-12-04 Parker Lougheed Fix error when using base element href (#3256) c3663762 2022-12-04 Parker Lougheed Add unnecessary override ignore to fix build (#3257) Change-Id: I21fc9ecd36db78b7ef420bd179af4907e667557d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279320 Reviewed-by: Kevin Moore <kevmoo@google.com> Commit-Queue: Kevin Chisholm <kevinjchisholm@google.com>
This issue was originally filed by reng...@gmail.com
What steps will reproduce the problem?
#import('/Applications/Dart/dart-sdk/lib/unittest/unittest.dart');
void main() {
test('compare empty list', () {
expect([]).equals([]);
});
test('compare one element list', () {
expect([1]).equals([1]);
});
test('compare longer list', () {
expect([1, 2, 3]).equals([1, 2, 3]);
});
}
What is the expected output?
3 PASSED, 0 FAILED, 0 ERRORS
What do you see instead?
FAIL: compare empty list
Expect.equals(expected: <[]>, actual: <[]>) fails.
0. Function: 'Expect._fail@127eafe4' url: 'bootstrap' line:563 col:66
1. Function: 'Expect.equals' url: 'bootstrap' line:518 col:173
2. Function: 'Expectation.equals' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/expectation.dart' line:27 col:20
3. Function: '::function' url: 'file:///Users/renggli/dart/TestTester/TestTester.dart' line:5 col:22
4. Function: '::function' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:521 col:20
5. Function: '::guardAsync' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:485 col:19
FAIL: compare one element list
Expect.equals(expected: <[1]>, actual: <[1]>) fails.
0. Function: 'Expect._fail@127eafe4' url: 'bootstrap' line:563 col:66
1. Function: 'Expect.equals' url: 'bootstrap' line:518 col:173
2. Function: 'Expectation.equals' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/expectation.dart' line:27 col:20
3. Function: '::function' url: 'file:///Users/renggli/dart/TestTester/TestTester.dart' line:8 col:23
4. Function: '::function' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:521 col:20
5. Function: '::guardAsync' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:485 col:19
FAIL: compare longer list
Expect.equals(expected: <[1, 2, 3]>, actual: <[1, 2, 3]>) fails.
0. Function: 'Expect._fail@127eafe4' url: 'bootstrap' line:563 col:66
1. Function: 'Expect.equals' url: 'bootstrap' line:518 col:173
2. Function: 'Expectation.equals' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/expectation.dart' line:27 col:20
3. Function: '::function' url: 'file:///Users/renggli/dart/TestTester/TestTester.dart' line:11 col:29
4. Function: '::function' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:521 col:20
5. Function: '::guardAsync' url: 'file:///Applications/Dart/dart-sdk/lib/unittest/unittest.dart' line:485 col:19
0 PASSED, 3 FAILED, 0 ERRORS
What version of the product are you using? On what operating system?
Dart SDK version 7904
Please provide any additional information below.
The problem can be fixed by adding the following snippet to Expectation.equals():
} else if (_value is List && expected is List) {
Expect.listEquals(expected, _value);
The text was updated successfully, but these errors were encountered: