Skip to content

Commit

Permalink
Test any without elements
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Dec 6, 2018
1 parent f8d776d commit 456fd96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/k_iterable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ abstract class KIterableExtension<T> {

/**
* Returns `true` if at least one element matches the given [predicate].
*
* Returns `true` if collection has at least one element when no [predicate] is provided
*/
bool any([bool Function(T element) predicate]);

Expand Down
8 changes: 8 additions & 0 deletions test/collection/iterable_extensions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ void testIterable(KIterable<T> Function<T>() emptyIterable,
final iterable = iterableOf(["abc", "bcd", "cde"]);
expect(iterable.any((e) => e.contains("x")), isFalse);
});
test("any without args returns true with items", () {
final iterable = iterableOf(["abc", "bcd", "cde"]);
expect(iterable.any(), isTrue);
});
test("any without args returns false for no items", () {
final iterable = emptyIterable();
expect(iterable.any(), isFalse);
});
});

group('associate', () {
Expand Down

0 comments on commit 456fd96

Please sign in to comment.