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

Unified Diff: packages/quiver/test/core/optional_test.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
« no previous file with comments | « packages/quiver/test/collection/treeset_test.dart ('k') | packages/quiver/test/io_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/quiver/test/core/optional_test.dart
diff --git a/packages/quiver/test/core/optional_test.dart b/packages/quiver/test/core/optional_test.dart
index 0072ba15da757dd50fa5df277791d799c1d0c89c..df615669230b19f69981d0cd196faa73a42b7039 100644
--- a/packages/quiver/test/core/optional_test.dart
+++ b/packages/quiver/test/core/optional_test.dart
@@ -70,25 +70,29 @@ main() {
test('transform should return transformed value or absent', () {
expect(new Optional<int>.fromNullable(7).transform((a) => a + 1),
equals(new Optional<int>.of(8)));
- expect(new Optional<int>.fromNullable(null)
- .transform((a) => a + 1).isPresent, isFalse);
+ expect(
+ new Optional<int>.fromNullable(null)
+ .transform((a) => a + 1)
+ .isPresent,
+ isFalse);
});
test('hashCode should allow optionals to be in hash sets', () {
- expect(new Set.from([
- new Optional<int>.of(7),
- new Optional<int>.of(8),
- new Optional<int>.absent()
- ]), equals(new Set.from([
- new Optional<int>.of(7),
- new Optional<int>.of(8),
- new Optional<int>.absent()
- ])));
- expect(new Set.from([
- new Optional<int>.of(7),
- new Optional<int>.of(8)
- ]), isNot(equals(
- new Set.from([new Optional<int>.of(7), new Optional<int>.of(9)]))));
+ expect(
+ new Set.from([
+ new Optional<int>.of(7),
+ new Optional<int>.of(8),
+ new Optional<int>.absent()
+ ]),
+ equals(new Set.from([
+ new Optional<int>.of(7),
+ new Optional<int>.of(8),
+ new Optional<int>.absent()
+ ])));
+ expect(
+ new Set.from([new Optional<int>.of(7), new Optional<int>.of(8)]),
+ isNot(equals(new Set.from(
+ [new Optional<int>.of(7), new Optional<int>.of(9)]))));
});
test('== should compare by value', () {
@@ -106,5 +110,22 @@ main() {
expect(new Optional<int>.fromNullable(null).toString(),
equals('Optional { absent }'));
});
+
+ test('length when absent should return 0', () {
+ expect(const Optional.absent().length, equals(0));
+ });
+
+ test('length when present should return 1', () {
+ expect(new Optional<int>.of(1).length, equals(1));
+ });
+
+ test('expand should behave as equivalent iterable', () {
+ final optionals = <Optional<int>>[
+ new Optional<int>.of(1),
+ const Optional.absent(),
+ new Optional<int>.of(2)
+ ].expand((i) => i);
+ expect(optionals, orderedEquals([1, 2]));
+ });
});
}
« no previous file with comments | « packages/quiver/test/collection/treeset_test.dart ('k') | packages/quiver/test/io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698