Add travis and dartfmt. (#57)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..db953f8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,20 @@
+language: dart
+sudo: false
+dart:
+ - dev
+ - stable
+cache:
+ directories:
+ - $HOME/.pub-cache
+dart_task:
+ - test: --platform vm
+ - test: --platform chrome
+ - test: --platform dartium
+ install_dartium: true
+ - dartanalyzer
+ - dartfmt
+matrix:
+ # Only run dartfmt checks with stable.
+ exclude:
+ - dart: dev
+ dart_task: dartfmt
diff --git a/lib/src/algorithms.dart b/lib/src/algorithms.dart
index d8ca102..fbf33ec 100644
--- a/lib/src/algorithms.dart
+++ b/lib/src/algorithms.dart
@@ -79,7 +79,6 @@
}
}
-
/// Reverses a list, or a part of a list, in-place.
void reverse(List list, [int start = 0, int end = null]) {
if (end == null) end = list.length;
@@ -110,8 +109,8 @@
///
/// This insertion sort is stable: Equal elements end up in the same order
/// as they started in.
-void insertionSort/*<T>*/(List/*<T>*/ list, {int compare(/*=T*/ a, /*=T*/ b),
- int start: 0, int end}) {
+void insertionSort/*<T>*/(List/*<T>*/ list,
+ {int compare(/*=T*/ a, /*=T*/ b), int start: 0, int end}) {
// If the same method could have both positional and named optional
// parameters, this should be (list, [start, end], {compare}).
compare ??= defaultCompare/*<T>*/();
@@ -153,8 +152,8 @@
///
/// This merge sort is stable: Equal elements end up in the same order
/// as they started in.
-void mergeSort/*<T>*/(List/*<T>*/ list, {int start: 0, int end,
- int compare(/*=T*/ a, /*=T*/ b)}) {
+void mergeSort/*<T>*/(List/*<T>*/ list,
+ {int start: 0, int end, int compare(/*=T*/ a, /*=T*/ b)}) {
end ??= list.length;
compare ??= defaultCompare/*<T>*/();
@@ -178,18 +177,20 @@
_mergeSort(list, compare, middle, end, scratchSpace, 0);
int firstTarget = end - firstLength;
_mergeSort(list, compare, start, middle, list, firstTarget);
- _merge(compare,
- list, firstTarget, end,
- scratchSpace, 0, secondLength,
- list, start);
+ _merge(compare, list, firstTarget, end, scratchSpace, 0, secondLength, list,
+ start);
}
/// Performs an insertion sort into a potentially different list than the
/// one containing the original values.
///
/// It will work in-place as well.
-void _movingInsertionSort/*<T>*/(List/*<T>*/ list,
- int compare(/*=T*/ a, /*=T*/ b), int start, int end, List/*<T>*/ target,
+void _movingInsertionSort/*<T>*/(
+ List/*<T>*/ list,
+ int compare(/*=T*/ a, /*=T*/ b),
+ int start,
+ int end,
+ List/*<T>*/ target,
int targetOffset) {
int length = end - start;
if (length == 0) return;
@@ -206,8 +207,7 @@
min = mid + 1;
}
}
- target.setRange(min + 1, targetOffset + i + 1,
- target, min);
+ target.setRange(min + 1, targetOffset + i + 1, target, min);
target[min] = element;
}
}
@@ -232,16 +232,12 @@
// Here secondLength >= firstLength (differs by at most one).
int targetMiddle = targetOffset + firstLength;
// Sort the second half into the end of the target area.
- _mergeSort(list, compare, middle, end,
- target, targetMiddle);
+ _mergeSort(list, compare, middle, end, target, targetMiddle);
// Sort the first half into the end of the source area.
- _mergeSort(list, compare, start, middle,
- list, middle);
+ _mergeSort(list, compare, start, middle, list, middle);
// Merge the two parts into the target area.
- _merge(compare,
- list, middle, middle + firstLength,
- target, targetMiddle, targetMiddle + secondLength,
- target, targetOffset);
+ _merge(compare, list, middle, middle + firstLength, target, targetMiddle,
+ targetMiddle + secondLength, target, targetOffset);
}
/// Merges two lists into a target list.
@@ -252,10 +248,16 @@
/// For equal object, elements from [firstList] are always preferred.
/// This allows the merge to be stable if the first list contains elements
/// that started out earlier than the ones in [secondList]
-void _merge/*<T>*/(int compare(/*=T*/ a, /*=T*/ b),
- List/*<T>*/ firstList, int firstStart, int firstEnd,
- List/*<T>*/ secondList, int secondStart, int secondEnd,
- List/*<T>*/ target, int targetOffset) {
+void _merge/*<T>*/(
+ int compare(/*=T*/ a, /*=T*/ b),
+ List/*<T>*/ firstList,
+ int firstStart,
+ int firstEnd,
+ List/*<T>*/ secondList,
+ int secondStart,
+ int secondEnd,
+ List/*<T>*/ target,
+ int targetOffset) {
// No empty lists reaches here.
assert(firstStart < firstEnd);
assert(secondStart < secondEnd);
@@ -266,7 +268,7 @@
while (true) {
if (compare(firstElement, secondElement) <= 0) {
target[targetOffset++] = firstElement;
- if (cursor1 == firstEnd) break; // Flushing second list after loop.
+ if (cursor1 == firstEnd) break; // Flushing second list after loop.
firstElement = firstList[cursor1++];
} else {
target[targetOffset++] = secondElement;
@@ -283,6 +285,6 @@
}
// First list empties first. Reached by break above.
target[targetOffset++] = secondElement;
- target.setRange(targetOffset, targetOffset + (secondEnd - cursor2),
- secondList, cursor2);
+ target.setRange(
+ targetOffset, targetOffset + (secondEnd - cursor2), secondList, cursor2);
}
diff --git a/lib/src/canonicalized_map.dart b/lib/src/canonicalized_map.dart
index cc78105..a8af43a 100644
--- a/lib/src/canonicalized_map.dart
+++ b/lib/src/canonicalized_map.dart
@@ -48,7 +48,7 @@
/// methods that take arbitrary objects. It can be used to filter out keys
/// that can't be canonicalized.
CanonicalizedMap.from(Map<K, V> other, C canonicalize(K key),
- {bool isValidKey(Object key)})
+ {bool isValidKey(Object key)})
: _canonicalize = canonicalize,
_isValidKeyFn = isValidKey {
addAll(other);
@@ -94,8 +94,9 @@
int get length => _base.length;
V putIfAbsent(K key, V ifAbsent()) {
- return _base.putIfAbsent(_canonicalize(key),
- () => new Pair(key, ifAbsent())).last;
+ return _base
+ .putIfAbsent(_canonicalize(key), () => new Pair(key, ifAbsent()))
+ .last;
}
V remove(Object key) {
@@ -108,6 +109,7 @@
String toString() => Maps.mapToString(this);
- bool _isValidKey(Object key) => (key == null || key is K) &&
+ bool _isValidKey(Object key) =>
+ (key == null || key is K) &&
(_isValidKeyFn == null || _isValidKeyFn(key));
}
diff --git a/lib/src/comparators.dart b/lib/src/comparators.dart
index b0824a8..5fc55b2 100644
--- a/lib/src/comparators.dart
+++ b/lib/src/comparators.dart
@@ -3,11 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
// Character constants.
-const int _zero = 0x30;
-const int _upperCaseA = 0x41;
-const int _upperCaseZ = 0x5a;
-const int _lowerCaseA = 0x61;
-const int _lowerCaseZ = 0x7a;
+const int _zero = 0x30;
+const int _upperCaseA = 0x41;
+const int _upperCaseZ = 0x5a;
+const int _lowerCaseA = 0x61;
+const int _lowerCaseZ = 0x7a;
const int _asciiCaseBit = 0x20;
/// Checks if strings [a] and [b] differ only on the case of ASCII letters.
@@ -43,7 +43,6 @@
return true;
}
-
/// Hash code for a string which is compatible with [equalsIgnoreAsciiCase].
///
/// The hash code is unaffected by changing the case of ASCII letters, but
@@ -69,7 +68,6 @@
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
-
/// Compares [a] and [b] lexically, converting ASCII letters to upper case.
///
/// Comparison treats all lower-case ASCII letters as upper-case letters,
@@ -107,7 +105,6 @@
return defaultResult.sign;
}
-
/// Compares [a] and [b] lexically, converting ASCII letters to lower case.
///
/// Comparison treats all upper-case ASCII letters as lower-case letters,
@@ -258,8 +255,7 @@
/// is a digit, and if so, the the one with the digit is the greater number.
///
/// Otherwise just returns the difference between [aChar] and [bChar].
-int _compareNaturally(
- String a, String b, int index, int aChar, int bChar) {
+int _compareNaturally(String a, String b, int index, int aChar, int bChar) {
assert(aChar != bChar);
var aIsDigit = _isDigit(aChar);
var bIsDigit = _isDigit(bChar);
@@ -302,14 +298,14 @@
if (aChar == _zero) {
do {
aIndex++;
- if (aIndex == a.length) return -1; // number in a is zero, b is not.
+ if (aIndex == a.length) return -1; // number in a is zero, b is not.
aChar = a.codeUnitAt(aIndex);
} while (aChar == _zero);
if (!_isDigit(aChar)) return -1;
} else if (bChar == _zero) {
do {
bIndex++;
- if (bIndex == b.length) return 1; // number in b is zero, a is not.
+ if (bIndex == b.length) return 1; // number in b is zero, a is not.
bChar = b.codeUnitAt(bIndex);
} while (bChar == _zero);
if (!_isDigit(bChar)) return 1;
@@ -343,7 +339,7 @@
// bChar is non-digit, so a has longer number.
return 1;
} else if (bIsDigit) {
- return -1; // b has longer number.
+ return -1; // b has longer number.
} else {
// Neither is digit, so numbers had same numerical value.
// Fall back on number of leading zeros
diff --git a/lib/src/empty_unmodifiable_set.dart b/lib/src/empty_unmodifiable_set.dart
index 581532f..69212a7 100644
--- a/lib/src/empty_unmodifiable_set.dart
+++ b/lib/src/empty_unmodifiable_set.dart
@@ -11,7 +11,7 @@
/// An unmodifiable, empty set that can have a const constructor.
class EmptyUnmodifiableSet<E> extends IterableBase<E>
implements UnmodifiableSetView<E> {
- static /*=T*/ _throw/*<T>*/() {
+ static/*=T*/ _throw/*<T>*/() {
throw new UnsupportedError("Cannot modify an unmodifiable Set");
}
@@ -37,4 +37,3 @@
void retainWhere(bool test(E element)) => _throw();
void retainAll(Iterable<Object> elements) => _throw();
}
-
diff --git a/lib/src/equality.dart b/lib/src/equality.dart
index 3b10176..aa5effa 100644
--- a/lib/src/equality.dart
+++ b/lib/src/equality.dart
@@ -96,8 +96,8 @@
/// Two iterables are equal if they have the same elements in the same order.
class IterableEquality<E> implements Equality<Iterable<E>> {
final Equality<E> _elementEquality;
- const IterableEquality([Equality<E> elementEquality =
- const DefaultEquality()])
+ const IterableEquality(
+ [Equality<E> elementEquality = const DefaultEquality()])
: _elementEquality = elementEquality;
bool equals(Iterable<E> elements1, Iterable<E> elements2) {
@@ -238,8 +238,7 @@
/// This equality behaves the same as [UnorderedIterableEquality] except that
/// it expects sets instead of iterables as arguments.
class SetEquality<E> extends _UnorderedEquality<E, Set<E>> {
- const SetEquality(
- [Equality<E> elementEquality = const DefaultEquality()])
+ const SetEquality([Equality<E> elementEquality = const DefaultEquality()])
: super(elementEquality);
bool isValidKey(Object o) => o is Set<E>;
@@ -257,14 +256,14 @@
int get hashCode =>
(3 * equality._keyEquality.hash(key) +
- 7 * equality._valueEquality.hash(value)) & _HASH_MASK;
+ 7 * equality._valueEquality.hash(value)) &
+ _HASH_MASK;
- bool operator==(Object other) {
+ bool operator ==(Object other) {
if (other is! _MapEntry) return false;
_MapEntry otherEntry = other;
return equality._keyEquality.equals(key, otherEntry.key) &&
- equality._valueEquality.equals(value, otherEntry.value);
-
+ equality._valueEquality.equals(value, otherEntry.value);
}
}
@@ -275,9 +274,11 @@
class MapEquality<K, V> implements Equality<Map<K, V>> {
final Equality<K> _keyEquality;
final Equality<V> _valueEquality;
- const MapEquality({ Equality<K> keys : const DefaultEquality(),
- Equality<V> values : const DefaultEquality() })
- : _keyEquality = keys, _valueEquality = values;
+ const MapEquality(
+ {Equality<K> keys: const DefaultEquality(),
+ Equality<V> values: const DefaultEquality()})
+ : _keyEquality = keys,
+ _valueEquality = values;
bool equals(Map<K, V> e1, Map<K, V> e2) {
if (identical(e1, e2)) return true;
@@ -377,14 +378,16 @@
final Equality _base;
final bool _unordered;
const DeepCollectionEquality([Equality base = const DefaultEquality()])
- : _base = base, _unordered = false;
+ : _base = base,
+ _unordered = false;
/// Creates a deep equality on collections where the order of lists and
/// iterables are not considered important. That is, lists and iterables are
/// treated as unordered iterables.
const DeepCollectionEquality.unordered(
[Equality base = const DefaultEquality()])
- : _base = base, _unordered = true;
+ : _base = base,
+ _unordered = true;
bool equals(e1, e2) {
if (e1 is Set) {
diff --git a/lib/src/equality_map.dart b/lib/src/equality_map.dart
index 686e5bd..14f074c 100644
--- a/lib/src/equality_map.dart
+++ b/lib/src/equality_map.dart
@@ -29,4 +29,3 @@
addAll(other);
}
}
-
diff --git a/lib/src/equality_set.dart b/lib/src/equality_set.dart
index b0582ce..6f6a426 100644
--- a/lib/src/equality_set.dart
+++ b/lib/src/equality_set.dart
@@ -29,4 +29,3 @@
addAll(other);
}
}
-
diff --git a/lib/src/functions.dart b/lib/src/functions.dart
index 6e5bb0a..14fff53 100644
--- a/lib/src/functions.dart
+++ b/lib/src/functions.dart
@@ -9,7 +9,7 @@
// TODO(nweiz): When sdk#26488 is fixed, use overloads to ensure that if [key]
// or [value] isn't passed, `K2`/`V2` defaults to `K1`/`V1`, respectively.
-/// Creates a new map from [map] with new keys and values.
+/// Creates a new map from [map] with new keys and values.
///
/// The return values of [key] are used as the keys and the return values of
/// [value] are used as the values for the new map.
@@ -19,7 +19,7 @@
key ??= (mapKey, _) => mapKey as dynamic/*=K2*/;
value ??= (_, mapValue) => mapValue as dynamic/*=V2*/;
- var result = /*<K2, V2>*/{};
+ var result = /*<K2, V2>*/ {};
map.forEach((mapKey, mapValue) {
result[key(mapKey, mapValue)] = value(mapKey, mapValue);
});
@@ -33,13 +33,12 @@
/// values. If [value] is omitted, the value from [map2] is used.
Map/*<K, V>*/ mergeMaps/*<K, V>*/(Map/*<K, V>*/ map1, Map/*<K, V>*/ map2,
{/*=V*/ value(/*=V*/ value1, /*=V*/ value2)}) {
- var result = new Map/*<K, V>*/.from(map1);
+ var result = new Map/*<K, V>*/ .from(map1);
if (value == null) return result..addAll(map2);
map2.forEach((key, mapValue) {
- result[key] = result.containsKey(key)
- ? value(result[key], mapValue)
- : mapValue;
+ result[key] =
+ result.containsKey(key) ? value(result[key], mapValue) : mapValue;
});
return result;
}
@@ -49,9 +48,10 @@
/// Returns a map from keys computed by [key] to a list of all values for which
/// [key] returns that key. The values appear in the list in the same relative
/// order as in [values].
-Map<dynamic/*=T*/, List/*<S>*/> groupBy/*<S, T>*/(Iterable/*<S>*/ values,
+Map<dynamic/*=T*/, List/*<S>*/ > groupBy/*<S, T>*/(
+ Iterable/*<S>*/ values,
/*=T*/ key(/*=S*/ element)) {
- var map = /*<T, List<S>>*/{};
+ var map = /*<T, List<S>>*/ {};
for (var element in values) {
var list = map.putIfAbsent(key(element), () => []);
list.add(element);
@@ -114,15 +114,15 @@
/// that vertex has no outgoing edges. This isn't checked, but if it's not
/// satisfied, the function may crash or provide unexpected output. For example,
/// `{"a": ["b"]}` is not valid, but `{"a": ["b"], "b": []}` is.
-Map<dynamic/*=T*/, Set/*<T>*/> transitiveClosure/*<T>*/(
- Map<dynamic/*=T*/, Iterable/*<T>*/> graph) {
+Map<dynamic/*=T*/, Set/*<T>*/ > transitiveClosure/*<T>*/(
+ Map<dynamic/*=T*/, Iterable/*<T>*/ > graph) {
// This uses [Warshall's algorithm][], modified not to add a vertex from each
// node to itself.
//
// [Warshall's algorithm]: https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm#Applications_and_generalizations.
- var result = /*<T, Set>*/{};
+ var result = /*<T, Set>*/ {};
graph.forEach((vertex, edges) {
- result[vertex] = new Set/*<T>*/.from(edges);
+ result[vertex] = new Set/*<T>*/ .from(edges);
});
// Lists are faster to iterate than maps, so we create a list since we're
@@ -154,14 +154,14 @@
/// that vertex has no outgoing edges. This isn't checked, but if it's not
/// satisfied, the function may crash or provide unexpected output. For example,
/// `{"a": ["b"]}` is not valid, but `{"a": ["b"], "b": []}` is.
-List<Set/*<T>*/> stronglyConnectedComponents/*<T>*/(
- Map<dynamic/*=T*/, Iterable/*<T>*/> graph) {
+List<Set/*<T>*/ > stronglyConnectedComponents/*<T>*/(
+ Map<dynamic/*=T*/, Iterable/*<T>*/ > graph) {
// This uses [Tarjan's algorithm][].
//
// [Tarjan's algorithm]: https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
var index = 0;
- var stack = /*<T>*/[];
- var result = /*<Set<T>>*/[];
+ var stack = /*<T>*/ [];
+ var result = /*<Set<T>>*/ [];
// The order of these doesn't matter, so we use un-linked implementations to
// avoid unnecessary overhead.
diff --git a/lib/src/iterable_zip.dart b/lib/src/iterable_zip.dart
index 638c686..b983437 100644
--- a/lib/src/iterable_zip.dart
+++ b/lib/src/iterable_zip.dart
@@ -16,8 +16,7 @@
class IterableZip<T> extends IterableBase<List<T>> {
final Iterable<Iterable<T>> _iterables;
- IterableZip(Iterable<Iterable<T>> iterables)
- : this._iterables = iterables;
+ IterableZip(Iterable<Iterable<T>> iterables) : this._iterables = iterables;
/// Returns an iterator that combines values of the iterables' iterators
/// as long as they all have values.
diff --git a/lib/src/priority_queue.dart b/lib/src/priority_queue.dart
index e0f65b4..84c43c2 100644
--- a/lib/src/priority_queue.dart
+++ b/lib/src/priority_queue.dart
@@ -276,8 +276,8 @@
}
// Then go to the right sibling of the left-child.
position += 1;
- } while (position > _length); // Happens if last element is a left child.
- } while (position != 1); // At root again. Happens for right-most element.
+ } while (position > _length); // Happens if last element is a left child.
+ } while (position != 1); // At root again. Happens for right-most element.
return -1;
}
diff --git a/lib/src/queue_list.dart b/lib/src/queue_list.dart
index bf75f33..73c1f66 100644
--- a/lib/src/queue_list.dart
+++ b/lib/src/queue_list.dart
@@ -19,7 +19,9 @@
///
/// If [initialCapacity] is given, prepare the queue for at least that many
/// elements.
- QueueList([int initialCapacity]) : _head = 0, _tail = 0 {
+ QueueList([int initialCapacity])
+ : _head = 0,
+ _tail = 0 {
if (initialCapacity == null || initialCapacity < _INITIAL_CAPACITY) {
initialCapacity = _INITIAL_CAPACITY;
} else if (!_isPowerOf2(initialCapacity)) {
@@ -82,7 +84,9 @@
// Queue interface.
- void addLast(E element) { _add(element); }
+ void addLast(E element) {
+ _add(element);
+ }
void addFirst(E element) {
_head = (_head - 1) & (_table.length - 1);
@@ -125,7 +129,7 @@
int newTail = _tail + delta; // [delta] is negative.
if (newTail >= 0) {
_table.fillRange(newTail, _tail, null);
- } else {
+ } else {
newTail += _table.length;
_table.fillRange(0, _tail, null);
_table.fillRange(newTail, _table.length, null);
@@ -141,7 +145,7 @@
return _table[(_head + index) & (_table.length - 1)];
}
- void operator[]=(int index, E value) {
+ void operator []=(int index, E value) {
if (index < 0 || index >= length) {
throw new RangeError("Index $index must be in the range [0..$length).");
}
@@ -164,7 +168,7 @@
static int _nextPowerOf2(int number) {
assert(number > 0);
number = (number << 1) - 1;
- for(;;) {
+ for (;;) {
int nextNumber = number & (number - 1);
if (nextNumber == 0) return number;
number = nextNumber;
diff --git a/lib/src/typed_wrappers.dart b/lib/src/typed_wrappers.dart
index 9416d81..d4c2fde 100644
--- a/lib/src/typed_wrappers.dart
+++ b/lib/src/typed_wrappers.dart
@@ -66,7 +66,7 @@
E get single => _base.single as E;
E singleWhere(bool test(E element)) =>
- _base.singleWhere(_validate(test)) as E;
+ _base.singleWhere(_validate(test)) as E;
Iterable<E> skip(int n) => new TypeSafeIterable<E>(_base.skip(n));
diff --git a/lib/src/unmodifiable_wrappers.dart b/lib/src/unmodifiable_wrappers.dart
index 5efbee4..9e74348 100644
--- a/lib/src/unmodifiable_wrappers.dart
+++ b/lib/src/unmodifiable_wrappers.dart
@@ -19,14 +19,14 @@
/// You can, for example, [sort] the list.
/// Permitted operations defer to the wrapped list.
class NonGrowableListView<E> extends DelegatingList<E>
- with NonGrowableListMixin<E> {
+ with NonGrowableListMixin<E> {
NonGrowableListView(List<E> listBase) : super(listBase);
}
/// Mixin class that implements a throwing version of all list operations that
/// change the List's length.
abstract class NonGrowableListMixin<E> implements List<E> {
- static /*=T*/ _throw/*<T>*/() {
+ static/*=T*/ _throw/*<T>*/() {
throw new UnsupportedError(
"Cannot change the length of a fixed-length list");
}
@@ -105,7 +105,7 @@
/// Mixin class that implements a throwing version of all set operations that
/// change the Set.
abstract class UnmodifiableSetMixin<E> implements Set<E> {
- static /*=T*/ _throw/*<T>*/() {
+ static/*=T*/ _throw/*<T>*/() {
throw new UnsupportedError("Cannot modify an unmodifiable Set");
}
@@ -145,7 +145,7 @@
/// Mixin class that implements a throwing version of all map operations that
/// change the Map.
abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> {
- static /*=T*/ _throw/*<T>*/() {
+ static/*=T*/ _throw/*<T>*/() {
throw new UnsupportedError("Cannot modify an unmodifiable Map");
}
diff --git a/lib/src/wrappers.dart b/lib/src/wrappers.dart
index 92760f6..1b917de 100644
--- a/lib/src/wrappers.dart
+++ b/lib/src/wrappers.dart
@@ -106,7 +106,6 @@
base is Iterable/*<E>*/ ? base : new TypeSafeIterable/*<E>*/(base);
}
-
/// A [List] that delegates all operations to a base list.
///
/// This class can be used to hide non-`List` methods of a list object, or it
@@ -217,7 +216,6 @@
List<E> sublist(int start, [int end]) => _listBase.sublist(start, end);
}
-
/// A [Set] that delegates all operations to a base set.
///
/// This class can be used to hide non-`Set` methods of a set object, or it can
@@ -328,9 +326,13 @@
bool remove(Object object) => _baseQueue.remove(object);
- void removeWhere(bool test(E element)) { _baseQueue.removeWhere(test); }
+ void removeWhere(bool test(E element)) {
+ _baseQueue.removeWhere(test);
+ }
- void retainWhere(bool test(E element)) { _baseQueue.retainWhere(test); }
+ void retainWhere(bool test(E element)) {
+ _baseQueue.retainWhere(test);
+ }
E removeFirst() => _baseQueue.removeFirst();
@@ -450,8 +452,8 @@
/// Throws an [UnsupportedError] since there's no corresponding method for
/// [Map]s.
- E lookup(E element) => throw new UnsupportedError(
- "MapKeySet doesn't support lookup().");
+ E lookup(E element) =>
+ throw new UnsupportedError("MapKeySet doesn't support lookup().");
/// Returns a new set which contains all the elements of [this] and [other].
///
diff --git a/lib/wrappers.dart b/lib/wrappers.dart
index 541456e..13031f5 100644
--- a/lib/wrappers.dart
+++ b/lib/wrappers.dart
@@ -9,4 +9,3 @@
export "src/canonicalized_map.dart";
export "src/unmodifiable_wrappers.dart";
export "src/wrappers.dart";
-
diff --git a/test/algorithms_test.dart b/test/algorithms_test.dart
index 6e6f630..dbd2633 100644
--- a/test/algorithms_test.dart
+++ b/test/algorithms_test.dart
@@ -43,18 +43,19 @@
if (count == 10) fail("Shuffle didn't change order.");
} while (true);
});
- test("Shuffle sublist", (){
+ test("Shuffle sublist", () {
List l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
List c = l.toList();
shuffle(l, 4, 12);
- expect(const IterableEquality().equals(l.getRange(0, 4),
- c.getRange(0, 4)), isTrue);
- expect(const IterableEquality().equals(l.getRange(12, 16),
- c.getRange(12, 16)), isTrue);
- expect(const UnorderedIterableEquality().equals(l.getRange(4, 12),
- c.getRange(4, 12)),
- isTrue);
-
+ expect(const IterableEquality().equals(l.getRange(0, 4), c.getRange(0, 4)),
+ isTrue);
+ expect(
+ const IterableEquality().equals(l.getRange(12, 16), c.getRange(12, 16)),
+ isTrue);
+ expect(
+ const UnorderedIterableEquality()
+ .equals(l.getRange(4, 12), c.getRange(4, 12)),
+ isTrue);
});
test("binsearch0", () {
@@ -158,7 +159,7 @@
for (int i = 0; i < 25; i++) {
List list = new List(i);
for (int j = 0; j < i; j++) {
- list[j] = random.nextInt(25); // Expect some equal elements.
+ list[j] = random.nextInt(25); // Expect some equal elements.
}
insertionSort(list);
for (int j = 1; j < i; j++) {
@@ -196,7 +197,7 @@
for (int i = 0; i < 250; i += 1) {
List list = new List(i);
for (int j = 0; j < i; j++) {
- list[j] = random.nextInt(i); // Expect some equal elements.
+ list[j] = random.nextInt(i); // Expect some equal elements.
}
mergeSort(list);
for (int j = 1; j < i; j++) {
@@ -314,6 +315,7 @@
final int id;
C(this.id);
}
+
int compareC(C one, C other) => one.id - other.id;
class OC implements Comparable<OC> {
diff --git a/test/canonicalized_map_test.dart b/test/canonicalized_map_test.dart
index 19e6a48..437e44f 100644
--- a/test/canonicalized_map_test.dart
+++ b/test/canonicalized_map_test.dart
@@ -30,32 +30,20 @@
});
test("canonicalizes keys for addAll", () {
- map.addAll({
- "1": "value 1",
- "2": "value 2",
- "3": "value 3"
- });
+ map.addAll({"1": "value 1", "2": "value 2", "3": "value 3"});
expect(map["01"], equals("value 1"));
expect(map["02"], equals("value 2"));
expect(map["03"], equals("value 3"));
});
test("uses the final value for addAll collisions", () {
- map.addAll({
- "1": "value 1",
- "01": "value 2",
- "001": "value 3"
- });
+ map.addAll({"1": "value 1", "01": "value 2", "001": "value 3"});
expect(map.length, equals(1));
expect(map["0001"], equals("value 3"));
});
test("clear clears the map", () {
- map.addAll({
- "1": "value 1",
- "2": "value 2",
- "3": "value 3"
- });
+ map.addAll({"1": "value 1", "2": "value 2", "3": "value 3"});
expect(map, isNot(isEmpty));
map.clear();
expect(map, isEmpty);
@@ -73,8 +61,8 @@
test("canonicalizes keys for putIfAbsent", () {
map["1"] = "value";
- expect(map.putIfAbsent("01", () => throw "shouldn't run"),
- equals("value"));
+ expect(
+ map.putIfAbsent("01", () => throw "shouldn't run"), equals("value"));
expect(map.putIfAbsent("2", () => "new value"), equals("new value"));
});
@@ -137,12 +125,8 @@
});
test("values returns all values in the map", () {
- map.addAll({
- "1": "value 1",
- "01": "value 01",
- "2": "value 2",
- "03": "value 03"
- });
+ map.addAll(
+ {"1": "value 1", "01": "value 01", "2": "value 2", "03": "value 03"});
expect(map.values, equals(["value 01", "value 2", "value 03"]));
});
@@ -150,22 +134,16 @@
group("CanonicalizedMap.from", () {
test("canonicalizes its keys", () {
- var map = new CanonicalizedMap.from({
- "1": "value 1",
- "2": "value 2",
- "3": "value 3"
- }, int.parse);
+ var map = new CanonicalizedMap.from(
+ {"1": "value 1", "2": "value 2", "3": "value 3"}, int.parse);
expect(map["01"], equals("value 1"));
expect(map["02"], equals("value 2"));
expect(map["03"], equals("value 3"));
});
test("uses the final value for collisions", () {
- var map = new CanonicalizedMap.from({
- "1": "value 1",
- "01": "value 2",
- "001": "value 3"
- }, int.parse);
+ var map = new CanonicalizedMap.from(
+ {"1": "value 1", "01": "value 2", "001": "value 3"}, int.parse);
expect(map.length, equals(1));
expect(map["0001"], equals("value 3"));
});
diff --git a/test/combined_wrapper/iterable_test.dart b/test/combined_wrapper/iterable_test.dart
index a473a02..3301821 100644
--- a/test/combined_wrapper/iterable_test.dart
+++ b/test/combined_wrapper/iterable_test.dart
@@ -16,8 +16,8 @@
});
test('should combine multiple iterables with some empty ones', () {
- var combined = new CombinedIterableView(
- [iterable1, [], iterable2, [], iterable3, []]);
+ var combined =
+ new CombinedIterableView([iterable1, [], iterable2, [], iterable3, []]);
expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
});
diff --git a/test/combined_wrapper/list_test.dart b/test/combined_wrapper/list_test.dart
index e072097..1a00f32 100644
--- a/test/combined_wrapper/list_test.dart
+++ b/test/combined_wrapper/list_test.dart
@@ -14,13 +14,11 @@
var concat = []..addAll(list1)..addAll(list2)..addAll(list3);
// In every way possible this should test the same as an UnmodifiableListView.
- common.testUnmodifiableList(concat, new CombinedListView(
- [list1, list2, list3]
- ), 'combineLists');
+ common.testUnmodifiableList(
+ concat, new CombinedListView([list1, list2, list3]), 'combineLists');
- common.testUnmodifiableList(concat, new CombinedListView(
- [list1, [], list2, [], list3, []]
- ), 'combineLists');
+ common.testUnmodifiableList(concat,
+ new CombinedListView([list1, [], list2, [], list3, []]), 'combineLists');
test('should function as an empty list when no lists are passed', () {
var empty = new CombinedListView([]);
diff --git a/test/combined_wrapper/map_test.dart b/test/combined_wrapper/map_test.dart
index c447373..832fe36 100644
--- a/test/combined_wrapper/map_test.dart
+++ b/test/combined_wrapper/map_test.dart
@@ -14,13 +14,13 @@
var concat = {}..addAll(map1)..addAll(map2)..addAll(map3);
// In every way possible this should test the same as an UnmodifiableMapView.
- common.testReadMap(concat, new CombinedMapView(
- [map1, map2, map3]
- ), 'CombinedMapView');
+ common.testReadMap(
+ concat, new CombinedMapView([map1, map2, map3]), 'CombinedMapView');
- common.testReadMap(concat, new CombinedMapView(
- [map1, {}, map2, {}, map3, {}]
- ), 'CombinedMapView (some empty)');
+ common.testReadMap(
+ concat,
+ new CombinedMapView([map1, {}, map2, {}, map3, {}]),
+ 'CombinedMapView (some empty)');
test('should function as an empty map when no maps are passed', () {
var empty = new CombinedMapView([]);
diff --git a/test/comparators_test.dart b/test/comparators_test.dart
index 169c688..aa868d9 100644
--- a/test/comparators_test.dart
+++ b/test/comparators_test.dart
@@ -57,63 +57,63 @@
"~"
];
- sortedBy(compare) => strings.toList()..shuffle()..sort(compare);
+ sortedBy(compare) => strings.toList()
+ ..shuffle()
+ ..sort(compare);
test("String.compareTo", () {
expect(sortedBy(null), strings);
});
test("compareAsciiLowerCase", () {
- expect(sortedBy(compareAsciiLowerCase),
- sortedBy((a, b) {
- int delta = a.toLowerCase().compareTo(b.toLowerCase());
- if (delta != 0) return delta;
- if (a == b) return 0;
- return a.compareTo(b);
- }));
+ expect(sortedBy(compareAsciiLowerCase), sortedBy((a, b) {
+ int delta = a.toLowerCase().compareTo(b.toLowerCase());
+ if (delta != 0) return delta;
+ if (a == b) return 0;
+ return a.compareTo(b);
+ }));
});
test("compareAsciiUpperCase", () {
- expect(sortedBy(compareAsciiUpperCase),
- sortedBy((a, b) {
- int delta = a.toUpperCase().compareTo(b.toUpperCase());
- if (delta != 0) return delta;
- if (a == b) return 0;
- return a.compareTo(b);
- }));
+ expect(sortedBy(compareAsciiUpperCase), sortedBy((a, b) {
+ int delta = a.toUpperCase().compareTo(b.toUpperCase());
+ if (delta != 0) return delta;
+ if (a == b) return 0;
+ return a.compareTo(b);
+ }));
});
// Replace any digit sequence by ("0", value, length) as char codes.
// This will sort alphabetically (by charcode) the way digits sort
// numerically, and the leading 0 means it sorts like a digit
// compared to non-digits.
- replaceNumbers(String string) => string.replaceAllMapped(new RegExp(r"\d+"), (m) {
- var digits = m[0];
- return new String.fromCharCodes([0x30, int.parse(digits), digits.length]);
- });
+ replaceNumbers(String string) =>
+ string.replaceAllMapped(new RegExp(r"\d+"), (m) {
+ var digits = m[0];
+ return new String.fromCharCodes(
+ [0x30, int.parse(digits), digits.length]);
+ });
test("compareNatural", () {
expect(sortedBy(compareNatural),
- sortedBy((a, b) => replaceNumbers(a).compareTo(replaceNumbers(b))));
+ sortedBy((a, b) => replaceNumbers(a).compareTo(replaceNumbers(b))));
});
test("compareAsciiLowerCaseNatural", () {
- expect(sortedBy(compareAsciiLowerCaseNatural),
- sortedBy((a, b) {
- int delta = replaceNumbers(a.toLowerCase()).compareTo(
- replaceNumbers(b.toLowerCase()));
- if (delta != 0) return delta;
- if (a == b) return 0;
- return a.compareTo(b);
- }));
+ expect(sortedBy(compareAsciiLowerCaseNatural), sortedBy((a, b) {
+ int delta = replaceNumbers(a.toLowerCase())
+ .compareTo(replaceNumbers(b.toLowerCase()));
+ if (delta != 0) return delta;
+ if (a == b) return 0;
+ return a.compareTo(b);
+ }));
});
test("compareAsciiUpperCaseNatural", () {
- expect(sortedBy(compareAsciiUpperCaseNatural),
- sortedBy((a, b) {
- int delta = replaceNumbers(a.toUpperCase()).compareTo(
- replaceNumbers(b.toUpperCase()));
- if (delta != 0) return delta;
- if (a == b) return 0;
- return a.compareTo(b);
- }));
+ expect(sortedBy(compareAsciiUpperCaseNatural), sortedBy((a, b) {
+ int delta = replaceNumbers(a.toUpperCase())
+ .compareTo(replaceNumbers(b.toUpperCase()));
+ if (delta != 0) return delta;
+ if (a == b) return 0;
+ return a.compareTo(b);
+ }));
});
}
diff --git a/test/equality_set_test.dart b/test/equality_set_test.dart
index 1b20684..a326b31 100644
--- a/test/equality_set_test.dart
+++ b/test/equality_set_test.dart
@@ -35,8 +35,8 @@
var list5 = [1, 2, 3];
var list6 = [1, 2, 3];
- var set = new EqualitySet.from(const IterableEquality(),
- [list1, list2, list3, list4, list5, list6]);
+ var set = new EqualitySet.from(
+ const IterableEquality(), [list1, list2, list3, list4, list5, list6]);
expect(set, contains(same(list1)));
expect(set, contains(same(list2)));
diff --git a/test/equality_test.dart b/test/equality_test.dart
index bdf8711..f407fab 100644
--- a/test/equality_test.dart
+++ b/test/equality_test.dart
@@ -32,31 +32,27 @@
});
test("ListEquality", () {
- expect(const ListEquality().equals(list1, list2),
- isTrue);
+ expect(const ListEquality().equals(list1, list2), isTrue);
Equality listId = const ListEquality(const IdentityEquality());
expect(listId.equals(list1, list2), isFalse);
});
test("ListInequality length", () {
var list4 = [o(1), o(2), o(3), o(4), o(5), o(6)];
- expect(const ListEquality().equals(list1, list4),
- isFalse);
+ expect(const ListEquality().equals(list1, list4), isFalse);
expect(const ListEquality(const IdentityEquality()).equals(list1, list4),
- isFalse);
+ isFalse);
});
test("ListInequality value", () {
var list5 = [o(1), o(2), o(3), o(4), o(6)];
- expect(const ListEquality().equals(list1, list5),
- isFalse);
+ expect(const ListEquality().equals(list1, list5), isFalse);
expect(const ListEquality(const IdentityEquality()).equals(list1, list5),
- isFalse);
+ isFalse);
});
test("UnorderedIterableEquality", () {
- expect(const UnorderedIterableEquality().equals(list1, list3),
- isTrue);
+ expect(const UnorderedIterableEquality().equals(list1, list3), isTrue);
Equality uniterId =
const UnorderedIterableEquality(const IdentityEquality());
expect(uniterId.equals(list1, list3), isFalse);
@@ -64,20 +60,20 @@
test("UnorderedIterableInequality length", () {
var list6 = [o(1), o(3), o(5), o(4), o(2), o(1)];
- expect(const UnorderedIterableEquality().equals(list1, list6),
- isFalse);
- expect(const UnorderedIterableEquality(const IdentityEquality())
- .equals(list1, list6),
- isFalse);
+ expect(const UnorderedIterableEquality().equals(list1, list6), isFalse);
+ expect(
+ const UnorderedIterableEquality(const IdentityEquality())
+ .equals(list1, list6),
+ isFalse);
});
test("UnorderedIterableInequality values", () {
var list7 = [o(1), o(3), o(5), o(4), o(6)];
- expect(const UnorderedIterableEquality().equals(list1, list7),
- isFalse);
- expect(const UnorderedIterableEquality(const IdentityEquality())
- .equals(list1, list7),
- isFalse);
+ expect(const UnorderedIterableEquality().equals(list1, list7), isFalse);
+ expect(
+ const UnorderedIterableEquality(const IdentityEquality())
+ .equals(list1, list7),
+ isFalse);
});
test("SetEquality", () {
@@ -92,26 +88,36 @@
var list8 = [o(1), o(3), o(5), o(4), o(2), o(6)];
var set1 = new HashSet.from(list1);
var set2 = new LinkedHashSet.from(list8);
- expect(const SetEquality().equals(set1, set2),
- isFalse);
+ expect(const SetEquality().equals(set1, set2), isFalse);
expect(const SetEquality(const IdentityEquality()).equals(set1, set2),
- isFalse);
+ isFalse);
});
test("SetInequality value", () {
var list7 = [o(1), o(3), o(5), o(4), o(6)];
var set1 = new HashSet.from(list1);
var set2 = new LinkedHashSet.from(list7);
- expect(const SetEquality().equals(set1, set2),
- isFalse);
+ expect(const SetEquality().equals(set1, set2), isFalse);
expect(const SetEquality(const IdentityEquality()).equals(set1, set2),
- isFalse);
+ isFalse);
});
- var map1a = {"x": [o(1), o(2), o(3)], "y": [true, false, null]};
- var map1b = {"x": [o(4), o(5), o(6)], "y": [false, true, null]};
- var map2a = {"x": [o(3), o(2), o(1)], "y": [false, true, null]};
- var map2b = {"x": [o(6), o(5), o(4)], "y": [null, false, true]};
+ var map1a = {
+ "x": [o(1), o(2), o(3)],
+ "y": [true, false, null]
+ };
+ var map1b = {
+ "x": [o(4), o(5), o(6)],
+ "y": [false, true, null]
+ };
+ var map2a = {
+ "x": [o(3), o(2), o(1)],
+ "y": [false, true, null]
+ };
+ var map2b = {
+ "x": [o(6), o(5), o(4)],
+ "y": [null, false, true]
+ };
var l1 = [map1a, map1b];
var l2 = [map2a, map2b];
var s1 = new Set<Map>.from(l1);
@@ -119,46 +125,29 @@
test("RecursiveEquality", () {
const unordered = const UnorderedIterableEquality();
- expect(unordered.equals(map1a["x"], map2a["x"]),
- isTrue);
- expect(unordered.equals(map1a["y"], map2a["y"]),
- isTrue);
- expect(unordered.equals(map1b["x"], map2b["x"]),
- isTrue);
- expect(unordered.equals(map1b["y"], map2b["y"]),
- isTrue);
+ expect(unordered.equals(map1a["x"], map2a["x"]), isTrue);
+ expect(unordered.equals(map1a["y"], map2a["y"]), isTrue);
+ expect(unordered.equals(map1b["x"], map2b["x"]), isTrue);
+ expect(unordered.equals(map1b["y"], map2b["y"]), isTrue);
const mapval = const MapEquality(values: unordered);
- expect(
- mapval.equals(map1a, map2a),
- isTrue);
- expect(mapval.equals(map1b, map2b),
- isTrue);
+ expect(mapval.equals(map1a, map2a), isTrue);
+ expect(mapval.equals(map1b, map2b), isTrue);
const listmapval = const ListEquality(mapval);
- expect(listmapval.equals(l1, l2),
- isTrue);
+ expect(listmapval.equals(l1, l2), isTrue);
const setmapval = const SetEquality<Map>(mapval);
- expect(setmapval.equals(s1, s2),
- isTrue);
+ expect(setmapval.equals(s1, s2), isTrue);
});
test("DeepEquality", () {
var colleq = const DeepCollectionEquality.unordered();
- expect(colleq.equals(map1a["x"], map2a["x"]),
- isTrue);
- expect(colleq.equals(map1a["y"], map2a["y"]),
- isTrue);
- expect(colleq.equals(map1b["x"], map2b["x"]),
- isTrue);
- expect(colleq.equals(map1b["y"], map2b["y"]),
- isTrue);
- expect(colleq.equals(map1a, map2a),
- isTrue);
- expect(colleq.equals(map1b, map2b),
- isTrue);
- expect(colleq.equals(l1, l2),
- isTrue);
- expect(colleq.equals(s1, s2),
- isTrue);
+ expect(colleq.equals(map1a["x"], map2a["x"]), isTrue);
+ expect(colleq.equals(map1a["y"], map2a["y"]), isTrue);
+ expect(colleq.equals(map1b["x"], map2b["x"]), isTrue);
+ expect(colleq.equals(map1b["y"], map2b["y"]), isTrue);
+ expect(colleq.equals(map1a, map2a), isTrue);
+ expect(colleq.equals(map1b, map2b), isTrue);
+ expect(colleq.equals(l1, l2), isTrue);
+ expect(colleq.equals(s1, s2), isTrue);
});
test("CaseInsensitiveEquality", () {
@@ -177,22 +166,15 @@
});
group("EqualityBy should use a derived value for ", () {
- var firstEquality = new EqualityBy<List<String>, String>(
- (e) => e.first);
+ var firstEquality = new EqualityBy<List<String>, String>((e) => e.first);
var firstInsensitiveEquality = new EqualityBy<List<String>, String>(
(e) => e.first, const CaseInsensitiveEquality());
var firstObjectEquality = new EqualityBy<List<Object>, Object>(
(e) => e.first, const IterableEquality());
test("equality", () {
- expect(
- firstEquality.equals(
- ["foo", "foo"], ["foo", "bar"]),
- isTrue);
- expect(
- firstEquality.equals(
- ["foo", "foo"], ["bar", "bar"]),
- isFalse);
+ expect(firstEquality.equals(["foo", "foo"], ["foo", "bar"]), isTrue);
+ expect(firstEquality.equals(["foo", "foo"], ["bar", "bar"]), isFalse);
});
test("equality with an inner equality", () {
@@ -205,8 +187,7 @@
});
test("hash with an inner equality", () {
- expect(
- firstInsensitiveEquality.hash(["fOo"]),
+ expect(firstInsensitiveEquality.hash(["fOo"]),
const CaseInsensitiveEquality().hash("foo"));
});
@@ -231,6 +212,6 @@
final Comparable id;
const Element(this.id);
int get hashCode => id.hashCode;
- bool operator==(Object other) => other is Element && id == other.id;
+ bool operator ==(Object other) => other is Element && id == other.id;
int compareTo(other) => id.compareTo(other.id);
}
diff --git a/test/functions_test.dart b/test/functions_test.dart
index 8eeba0a..d75f8cf 100644
--- a/test/functions_test.dart
+++ b/test/functions_test.dart
@@ -62,7 +62,8 @@
});
test("uses the callback to merge values", () {
- expect(mergeMaps({"foo": 1, "bar": 2}, {"bar": 3, "baz": 4},
+ expect(
+ mergeMaps({"foo": 1, "bar": 2}, {"bar": 3, "baz": 4},
value: (value1, value2) => value1 + value2),
equals({"foo": 1, "bar": 5, "baz": 4}));
});
@@ -76,7 +77,11 @@
test("groups elements by the function's return value", () {
expect(
groupBy(["foo", "bar", "baz", "bop", "qux"], (string) => string[1]),
- equals({"o": ["foo", "bop"], "a": ["bar", "baz"], "u": ["qux"]}));
+ equals({
+ "o": ["foo", "bop"],
+ "a": ["bar", "baz"],
+ "u": ["qux"]
+ }));
});
});
@@ -88,20 +93,29 @@
isNull);
});
- test("returns the element for which the ordering function returns the "
+ test(
+ "returns the element for which the ordering function returns the "
"smallest value", () {
expect(
- minBy(
- [{"foo": 3}, {"foo": 5}, {"foo": 4}, {"foo": 1}, {"foo": 2}],
- (map) => map["foo"]),
+ minBy([
+ {"foo": 3},
+ {"foo": 5},
+ {"foo": 4},
+ {"foo": 1},
+ {"foo": 2}
+ ], (map) => map["foo"]),
equals({"foo": 1}));
});
test("uses a custom comparator if provided", () {
expect(
- minBy(
- [{"foo": 3}, {"foo": 5}, {"foo": 4}, {"foo": 1}, {"foo": 2}],
- (map) => map,
+ minBy([
+ {"foo": 3},
+ {"foo": 5},
+ {"foo": 4},
+ {"foo": 1},
+ {"foo": 2}
+ ], (map) => map,
compare: (map1, map2) => map1["foo"].compareTo(map2["foo"])),
equals({"foo": 1}));
});
@@ -115,20 +129,29 @@
isNull);
});
- test("returns the element for which the ordering function returns the "
+ test(
+ "returns the element for which the ordering function returns the "
"largest value", () {
expect(
- maxBy(
- [{"foo": 3}, {"foo": 5}, {"foo": 4}, {"foo": 1}, {"foo": 2}],
- (map) => map["foo"]),
+ maxBy([
+ {"foo": 3},
+ {"foo": 5},
+ {"foo": 4},
+ {"foo": 1},
+ {"foo": 2}
+ ], (map) => map["foo"]),
equals({"foo": 5}));
});
test("uses a custom comparator if provided", () {
expect(
- maxBy(
- [{"foo": 3}, {"foo": 5}, {"foo": 4}, {"foo": 1}, {"foo": 2}],
- (map) => map,
+ maxBy([
+ {"foo": 3},
+ {"foo": 5},
+ {"foo": 4},
+ {"foo": 1},
+ {"foo": 2}
+ ], (map) => map,
compare: (map1, map2) => map1["foo"].compareTo(map2["foo"])),
equals({"foo": 5}));
});
@@ -140,45 +163,51 @@
});
test("returns the input when there are no transitive connections", () {
- expect(transitiveClosure({
- "foo": ["bar"],
- "bar": [],
- "bang": ["qux", "zap"],
- "qux": [],
- "zap": []
- }), equals({
- "foo": ["bar"],
- "bar": [],
- "bang": ["qux", "zap"],
- "qux": [],
- "zap": []
- }));
+ expect(
+ transitiveClosure({
+ "foo": ["bar"],
+ "bar": [],
+ "bang": ["qux", "zap"],
+ "qux": [],
+ "zap": []
+ }),
+ equals({
+ "foo": ["bar"],
+ "bar": [],
+ "bang": ["qux", "zap"],
+ "qux": [],
+ "zap": []
+ }));
});
test("flattens transitive connections", () {
- expect(transitiveClosure({
- "qux": [],
- "bar": ["baz"],
- "baz": ["qux"],
- "foo": ["bar"]
- }), equals({
- "foo": ["bar", "baz", "qux"],
- "bar": ["baz", "qux"],
- "baz": ["qux"],
- "qux": []
- }));
+ expect(
+ transitiveClosure({
+ "qux": [],
+ "bar": ["baz"],
+ "baz": ["qux"],
+ "foo": ["bar"]
+ }),
+ equals({
+ "foo": ["bar", "baz", "qux"],
+ "bar": ["baz", "qux"],
+ "baz": ["qux"],
+ "qux": []
+ }));
});
test("handles loops", () {
- expect(transitiveClosure({
- "foo": ["bar"],
- "bar": ["baz"],
- "baz": ["foo"]
- }), equals({
- "foo": ["bar", "baz", "foo"],
- "bar": ["baz", "foo", "bar"],
- "baz": ["foo", "bar", "baz"]
- }));
+ expect(
+ transitiveClosure({
+ "foo": ["bar"],
+ "bar": ["baz"],
+ "baz": ["foo"]
+ }),
+ equals({
+ "foo": ["bar", "baz", "foo"],
+ "bar": ["baz", "foo", "bar"],
+ "baz": ["foo", "bar", "baz"]
+ }));
});
});
@@ -188,90 +217,116 @@
});
test("returns one set for a singleton graph", () {
- expect(stronglyConnectedComponents({"a": []}),
- equals([new Set.from(["a"])]));
+ expect(
+ stronglyConnectedComponents({"a": []}),
+ equals([
+ new Set.from(["a"])
+ ]));
});
test("returns two sets for a two-element tree", () {
- expect(stronglyConnectedComponents({"a": ["b"], "b": []}),
- equals([new Set.from(["a"]), new Set.from(["b"])]));
+ expect(
+ stronglyConnectedComponents({
+ "a": ["b"],
+ "b": []
+ }),
+ equals([
+ new Set.from(["a"]),
+ new Set.from(["b"])
+ ]));
});
test("returns one set for a two-element loop", () {
- expect(stronglyConnectedComponents({"a": ["b"], "b": ["a"]}),
- equals([new Set.from(["a", "b"])]));
+ expect(
+ stronglyConnectedComponents({
+ "a": ["b"],
+ "b": ["a"]
+ }),
+ equals([
+ new Set.from(["a", "b"])
+ ]));
});
test("returns individual vertices for a tree", () {
- expect(stronglyConnectedComponents({
- "foo": ["bar"],
- "bar": ["baz", "bang"],
- "baz": ["qux"],
- "bang": ["zap"],
- "qux": [],
- "zap": []
- }), equals([
- // This is expected to return *a* topological ordering, but this isn't
- // the only valid one. If the function implementation changes in the
- // future, this test may need to be updated.
- new Set.from(["foo"]),
- new Set.from(["bar"]),
- new Set.from(["bang"]),
- new Set.from(["zap"]),
- new Set.from(["baz"]),
- new Set.from(["qux"])
- ]));
+ expect(
+ stronglyConnectedComponents({
+ "foo": ["bar"],
+ "bar": ["baz", "bang"],
+ "baz": ["qux"],
+ "bang": ["zap"],
+ "qux": [],
+ "zap": []
+ }),
+ equals([
+ // This is expected to return *a* topological ordering, but this isn't
+ // the only valid one. If the function implementation changes in the
+ // future, this test may need to be updated.
+ new Set.from(["foo"]),
+ new Set.from(["bar"]),
+ new Set.from(["bang"]),
+ new Set.from(["zap"]),
+ new Set.from(["baz"]),
+ new Set.from(["qux"])
+ ]));
});
test("returns a single set for a fully cyclic graph", () {
- expect(stronglyConnectedComponents({
- "foo": ["bar"],
- "bar": ["baz"],
- "baz": ["bang"],
- "bang": ["foo"]
- }), equals([new Set.from(["foo", "bar", "baz", "bang"])]));
+ expect(
+ stronglyConnectedComponents({
+ "foo": ["bar"],
+ "bar": ["baz"],
+ "baz": ["bang"],
+ "bang": ["foo"]
+ }),
+ equals([
+ new Set.from(["foo", "bar", "baz", "bang"])
+ ]));
});
test("returns separate sets for each strongly connected component", () {
// https://en.wikipedia.org/wiki/Strongly_connected_component#/media/File:Scc.png
- expect(stronglyConnectedComponents({
- "a": ["b"],
- "b": ["c", "e", "f"],
- "c": ["d", "g"],
- "d": ["c", "h"],
- "e": ["a", "f"],
- "f": ["g"],
- "g": ["f"],
- "h": ["g", "d"]
- }), equals([
- // This is expected to return *a* topological ordering, but this isn't
- // the only valid one. If the function implementation changes in the
- // future, this test may need to be updated.
- new Set.from(["a", "b", "e"]),
- new Set.from(["c", "d", "h"]),
- new Set.from(["f", "g"]),
- ]));
+ expect(
+ stronglyConnectedComponents({
+ "a": ["b"],
+ "b": ["c", "e", "f"],
+ "c": ["d", "g"],
+ "d": ["c", "h"],
+ "e": ["a", "f"],
+ "f": ["g"],
+ "g": ["f"],
+ "h": ["g", "d"]
+ }),
+ equals([
+ // This is expected to return *a* topological ordering, but this isn't
+ // the only valid one. If the function implementation changes in the
+ // future, this test may need to be updated.
+ new Set.from(["a", "b", "e"]),
+ new Set.from(["c", "d", "h"]),
+ new Set.from(["f", "g"]),
+ ]));
});
test("always returns components in topological order", () {
- expect(stronglyConnectedComponents({
- "bar": ["baz", "bang"],
- "zap": [],
- "baz": ["qux"],
- "qux": [],
- "foo": ["bar"],
- "bang": ["zap"]
- }), equals([
- // This is expected to return *a* topological ordering, but this isn't
- // the only valid one. If the function implementation changes in the
- // future, this test may need to be updated.
- new Set.from(["foo"]),
- new Set.from(["bar"]),
- new Set.from(["bang"]),
- new Set.from(["zap"]),
- new Set.from(["baz"]),
- new Set.from(["qux"])
- ]));
+ expect(
+ stronglyConnectedComponents({
+ "bar": ["baz", "bang"],
+ "zap": [],
+ "baz": ["qux"],
+ "qux": [],
+ "foo": ["bar"],
+ "bang": ["zap"]
+ }),
+ equals([
+ // This is expected to return *a* topological ordering, but this isn't
+ // the only valid one. If the function implementation changes in the
+ // future, this test may need to be updated.
+ new Set.from(["foo"]),
+ new Set.from(["bar"]),
+ new Set.from(["bang"]),
+ new Set.from(["zap"]),
+ new Set.from(["baz"]),
+ new Set.from(["qux"])
+ ]));
});
});
}
diff --git a/test/ignore_ascii_case_test.dart b/test/ignore_ascii_case_test.dart
index 787f76f..6aee455 100644
--- a/test/ignore_ascii_case_test.dart
+++ b/test/ignore_ascii_case_test.dart
@@ -34,7 +34,7 @@
var reason = "$s1 =?= $s2";
expect(equalsIgnoreAsciiCase(s1, s2), true, reason: reason);
expect(hashIgnoreAsciiCase(s1), hashIgnoreAsciiCase(s2),
- reason: reason);
+ reason: reason);
}
}
@@ -44,8 +44,9 @@
testChars(char1, char2, areEqual) {
expect(equalsIgnoreAsciiCase(char1, char2), areEqual,
- reason: "$char1 ${areEqual ? "=" : "!"}= $char2");
+ reason: "$char1 ${areEqual ? "=" : "!"}= $char2");
}
+
for (int i = 0; i < upperCaseLetters.length; i++) {
for (int j = 0; i < upperCaseLetters.length; i++) {
testChars(upperCaseLetters[i], upperCaseLetters[j], i == j);
@@ -55,4 +56,4 @@
}
}
});
-}
\ No newline at end of file
+}
diff --git a/test/iterable_zip_test.dart b/test/iterable_zip_test.dart
index 0679171..d4d5484 100644
--- a/test/iterable_zip_test.dart
+++ b/test/iterable_zip_test.dart
@@ -15,40 +15,103 @@
main() {
test("Basic", () {
- expect(new IterableZip([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9]
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Uneven length 1", () {
- expect(new IterableZip([[1, 2, 3, 99, 100], [4, 5, 6], [7, 8, 9]]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3, 99, 100],
+ [4, 5, 6],
+ [7, 8, 9]
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Uneven length 2", () {
- expect(new IterableZip([[1, 2, 3], [4, 5, 6, 99, 100], [7, 8, 9]]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6, 99, 100],
+ [7, 8, 9]
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Uneven length 3", () {
- expect(new IterableZip([[1, 2, 3], [4, 5, 6], [7, 8, 9, 99, 100]]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9, 99, 100]
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Uneven length 3", () {
- expect(new IterableZip([[1, 2, 3, 98], [4, 5, 6], [7, 8, 9, 99, 100]]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3, 98],
+ [4, 5, 6],
+ [7, 8, 9, 99, 100]
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Empty 1", () {
- expect(new IterableZip([[], [4, 5, 6], [7, 8, 9]]), equals([]));
+ expect(
+ new IterableZip([
+ [],
+ [4, 5, 6],
+ [7, 8, 9]
+ ]),
+ equals([]));
});
test("Empty 2", () {
- expect(new IterableZip([[1, 2, 3], [], [7, 8, 9]]), equals([]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [],
+ [7, 8, 9]
+ ]),
+ equals([]));
});
test("Empty 3", () {
- expect(new IterableZip([[1, 2, 3], [4, 5, 6], []]), equals([]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6],
+ []
+ ]),
+ equals([]));
});
test("Empty source", () {
@@ -56,59 +119,98 @@
});
test("Single Source", () {
- expect(new IterableZip([[1, 2, 3]]), equals([[1], [2], [3]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3]
+ ]),
+ equals([
+ [1],
+ [2],
+ [3]
+ ]));
});
test("Not-lists", () {
// Use other iterables than list literals.
Iterable it1 = [1, 2, 3, 4, 5, 6].where((x) => x < 4);
Set it2 = new LinkedHashSet()..add(4)..add(5)..add(6);
- Iterable it3 = (new LinkedHashMap()..[7] = 0 ..[8] = 0 ..[9] = 0).keys;
+ Iterable it3 = (new LinkedHashMap()
+ ..[7] = 0
+ ..[8] = 0
+ ..[9] = 0)
+ .keys;
Iterable<Iterable> allIts =
new Iterable.generate(3, (i) => [it1, it2, it3][i]);
- expect(new IterableZip(allIts),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip(allIts),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
test("Error 1", () {
- expect(() => new IterableZip([iterError([1, 2, 3], 2),
- [4, 5, 6],
- [7, 8, 9]]).toList(),
- throwsA(equals("BAD")));
+ expect(
+ () => new IterableZip([
+ iterError([1, 2, 3], 2),
+ [4, 5, 6],
+ [7, 8, 9]
+ ]).toList(),
+ throwsA(equals("BAD")));
});
test("Error 2", () {
- expect(() => new IterableZip([[1, 2, 3],
- iterError([4, 5, 6], 5),
- [7, 8, 9]]).toList(),
- throwsA(equals("BAD")));
+ expect(
+ () => new IterableZip([
+ [1, 2, 3],
+ iterError([4, 5, 6], 5),
+ [7, 8, 9]
+ ]).toList(),
+ throwsA(equals("BAD")));
});
test("Error 3", () {
- expect(() => new IterableZip([[1, 2, 3],
- [4, 5, 6],
- iterError([7, 8, 9], 8)]).toList(),
- throwsA(equals("BAD")));
+ expect(
+ () => new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6],
+ iterError([7, 8, 9], 8)
+ ]).toList(),
+ throwsA(equals("BAD")));
});
test("Error at end", () {
- expect(() => new IterableZip([[1, 2, 3],
- iterError([4, 5, 6], 6),
- [7, 8, 9]]).toList(),
- throwsA(equals("BAD")));
+ expect(
+ () => new IterableZip([
+ [1, 2, 3],
+ iterError([4, 5, 6], 6),
+ [7, 8, 9]
+ ]).toList(),
+ throwsA(equals("BAD")));
});
test("Error before first end", () {
- expect(() => new IterableZip([iterError([1, 2, 3, 4], 4),
- [4, 5, 6],
- [7, 8, 9]]).toList(),
- throwsA(equals("BAD")));
+ expect(
+ () => new IterableZip([
+ iterError([1, 2, 3, 4], 4),
+ [4, 5, 6],
+ [7, 8, 9]
+ ]).toList(),
+ throwsA(equals("BAD")));
});
test("Error after first end", () {
- expect(new IterableZip([[1, 2, 3],
- [4, 5, 6],
- iterError([7, 8, 9, 10], 10)]),
- equals([[1, 4, 7], [2, 5, 8], [3, 6, 9]]));
+ expect(
+ new IterableZip([
+ [1, 2, 3],
+ [4, 5, 6],
+ iterError([7, 8, 9, 10], 10)
+ ]),
+ equals([
+ [1, 4, 7],
+ [2, 5, 8],
+ [3, 6, 9]
+ ]));
});
}
diff --git a/test/priority_queue_test.dart b/test/priority_queue_test.dart
index 3131b15..0e493e5 100644
--- a/test/priority_queue_test.dart
+++ b/test/priority_queue_test.dart
@@ -16,8 +16,8 @@
void testDefault() {
test('new PriorityQueue() returns a HeapPriorityQueue', () {
- expect(new PriorityQueue<int>(),
- new isInstanceOf<HeapPriorityQueue<int>>());
+ expect(
+ new PriorityQueue<int>(), new isInstanceOf<HeapPriorityQueue<int>>());
});
testInt(() => new PriorityQueue<int>());
testCustom((comparator) => new PriorityQueue<C>(comparator));
@@ -25,27 +25,19 @@
void testInt(PriorityQueue<int> create()) {
for (int count in [1, 5, 127, 128]) {
- testQueue("int:$count",
- create,
- new List<int>.generate(count, (x) => x),
- count);
+ testQueue(
+ "int:$count", create, new List<int>.generate(count, (x) => x), count);
}
}
void testCustom(PriorityQueue<C> create(comparator)) {
for (int count in [1, 5, 127, 128]) {
- testQueue("Custom:$count/null",
- () => create(null),
- new List<C>.generate(count, (x) => new C(x)),
- new C(count));
- testQueue("Custom:$count/compare",
- () => create(compare),
- new List<C>.generate(count, (x) => new C(x)),
- new C(count));
- testQueue("Custom:$count/compareNeg",
- () => create(compareNeg),
- new List<C>.generate(count, (x) => new C(count - x)),
- new C(0));
+ testQueue("Custom:$count/null", () => create(null),
+ new List<C>.generate(count, (x) => new C(x)), new C(count));
+ testQueue("Custom:$count/compare", () => create(compare),
+ new List<C>.generate(count, (x) => new C(x)), new C(count));
+ testQueue("Custom:$count/compareNeg", () => create(compareNeg),
+ new List<C>.generate(count, (x) => new C(count - x)), new C(0));
}
}
@@ -60,8 +52,12 @@
PriorityQueue q = create();
expect(q.isEmpty, isTrue);
expect(q, hasLength(0));
- expect(() { q.first; }, throwsStateError);
- expect(() { q.removeFirst(); }, throwsStateError);
+ expect(() {
+ q.first;
+ }, throwsStateError);
+ expect(() {
+ q.removeFirst();
+ }, throwsStateError);
// Tests removeFirst, first, contains, toList and toSet.
void testElements() {
@@ -117,6 +113,7 @@
if (mid + 1 < max) addRec(mid + 1, max);
if (mid > min) addRec(min, mid);
}
+
addRec(0, elements.length);
testElements();
@@ -159,7 +156,6 @@
expect(q.isEmpty, isTrue);
}
-
// Custom class.
// Class is comparable, comparators match normal and inverse order.
int compare(C c1, C c2) => c1.value - c2.value;
@@ -169,7 +165,7 @@
final int value;
const C(this.value);
int get hashCode => value;
- bool operator==(Object other) => other is C && value == other.value;
+ bool operator ==(Object other) => other is C && value == other.value;
int compareTo(C other) => value - other.value;
String toString() => "C($value)";
}
diff --git a/test/queue_list_test.dart b/test/queue_list_test.dart
index deee459..9e6d199 100644
--- a/test/queue_list_test.dart
+++ b/test/queue_list_test.dart
@@ -69,7 +69,8 @@
expect(queue, equals([2, 3]));
});
- test("removes an element from the beginning of a queue with an internal "
+ test(
+ "removes an element from the beginning of a queue with an internal "
"gap", () {
var queue = withInternalGap();
expect(queue.removeFirst(), equals(1));
@@ -167,7 +168,8 @@
expect(() => queue[-1], throwsRangeError);
});
- test("throws a RangeError if the index is greater than or equal to the "
+ test(
+ "throws a RangeError if the index is greater than or equal to the "
"length", () {
var queue = new QueueList.from([1, 2, 3]);
expect(() => queue[3], throwsRangeError);
@@ -202,7 +204,8 @@
}, throwsRangeError);
});
- test("throws a RangeError if the index is greater than or equal to the "
+ test(
+ "throws a RangeError if the index is greater than or equal to the "
"length", () {
var queue = new QueueList.from([1, 2, 3]);
expect(() {
@@ -271,5 +274,5 @@
/// Returns a matcher that expects that a closure throws a
/// [ConcurrentModificationError].
-final throwsConcurrentModificationError = throwsA(
- new isInstanceOf<ConcurrentModificationError>());
+final throwsConcurrentModificationError =
+ throwsA(new isInstanceOf<ConcurrentModificationError>());
diff --git a/test/typed_wrapper/iterable_test.dart b/test/typed_wrapper/iterable_test.dart
index ff044da..b20dd27 100644
--- a/test/typed_wrapper/iterable_test.dart
+++ b/test/typed_wrapper/iterable_test.dart
@@ -13,12 +13,12 @@
var emptyWrapper;
var singleWrapper;
setUp(() {
- wrapper = DelegatingIterable.typed/*<int>*/(
- <Object>[1, 2, 3, 4, 5].map((i) => i));
- emptyWrapper = DelegatingIterable.typed/*<int>*/(
- <Object>[].map((i) => i));
- singleWrapper = DelegatingIterable.typed/*<int>*/(
- <Object>[1].map((i) => i));
+ wrapper = DelegatingIterable
+ .typed/*<int>*/(<Object>[1, 2, 3, 4, 5].map((i) => i));
+ emptyWrapper =
+ DelegatingIterable.typed/*<int>*/(<Object>[].map((i) => i));
+ singleWrapper =
+ DelegatingIterable.typed/*<int>*/(<Object>[1].map((i) => i));
});
test("any()", () {
@@ -130,8 +130,8 @@
test("reduce()", () {
expect(wrapper.reduce((value, i) => value + i), equals(15));
- expect(() => emptyWrapper.reduce((value, i) => value + i),
- throwsStateError);
+ expect(
+ () => emptyWrapper.reduce((value, i) => value + i), throwsStateError);
});
test("single", () {
@@ -142,8 +142,8 @@
test("singleWhere()", () {
expect(() => wrapper.singleWhere((i) => i.isOdd), throwsStateError);
expect(singleWrapper.singleWhere((i) => i.isOdd), equals(1));
- expect(() => singleWrapper.singleWhere((i) => i.isEven),
- throwsStateError);
+ expect(
+ () => singleWrapper.singleWhere((i) => i.isEven), throwsStateError);
});
test("skip()", () {
@@ -171,8 +171,8 @@
test("toList()", () {
expect(wrapper.toList(), equals([1, 2, 3, 4, 5]));
expect(wrapper.toList(growable: false), equals([1, 2, 3, 4, 5]));
- expect(() => wrapper.toList(growable: false).add(6),
- throwsUnsupportedError);
+ expect(
+ () => wrapper.toList(growable: false).add(6), throwsUnsupportedError);
});
test("toSet()", () {
@@ -198,8 +198,8 @@
setUp(() {
wrapper = DelegatingIterable.typed/*<int>*/(
<Object>["foo", "bar", "baz"].map((element) => element));
- singleWrapper = DelegatingIterable.typed/*<int>*/(
- <Object>["foo"].map((element) => element));
+ singleWrapper = DelegatingIterable
+ .typed/*<int>*/(<Object>["foo"].map((element) => element));
});
group("throws a CastError for", () {
@@ -232,7 +232,8 @@
});
test("fold()", () {
- expect(() => wrapper.fold(null, expectAsync2((_, __) => null, count: 0)),
+ expect(
+ () => wrapper.fold(null, expectAsync2((_, __) => null, count: 0)),
throwsCastError);
});
diff --git a/test/typed_wrapper/map_test.dart b/test/typed_wrapper/map_test.dart
index 30c6426..3ebf02b 100644
--- a/test/typed_wrapper/map_test.dart
+++ b/test/typed_wrapper/map_test.dart
@@ -29,14 +29,14 @@
expect(wrapper, equals({"foo": 5, "bar": 2, "baz": 3, "bang": 4}));
wrapper["qux"] = 6;
- expect(wrapper,
- equals({"foo": 5, "bar": 2, "baz": 3, "bang": 4, "qux": 6}));
+ expect(
+ wrapper, equals({"foo": 5, "bar": 2, "baz": 3, "bang": 4, "qux": 6}));
});
test("addAll()", () {
wrapper.addAll({"bar": 5, "qux": 6});
- expect(wrapper,
- equals({"foo": 1, "bar": 5, "baz": 3, "bang": 4, "qux": 6}));
+ expect(
+ wrapper, equals({"foo": 1, "bar": 5, "baz": 3, "bang": 4, "qux": 6}));
});
test("clear()", () {
@@ -59,8 +59,14 @@
test("forEach()", () {
var results = [];
wrapper.forEach((key, value) => results.add([key, value]));
- expect(results,
- unorderedEquals([["foo", 1], ["bar", 2], ["baz", 3], ["bang", 4]]));
+ expect(
+ results,
+ unorderedEquals([
+ ["foo", 1],
+ ["bar", 2],
+ ["baz", 3],
+ ["bang", 4]
+ ]));
emptyWrapper.forEach(expectAsync2((_, __) {}, count: 0));
});
@@ -90,8 +96,8 @@
equals(1));
expect(wrapper.putIfAbsent("qux", () => 6), equals(6));
- expect(wrapper,
- equals({"foo": 1, "bar": 2, "baz": 3, "bang": 4, "qux": 6}));
+ expect(
+ wrapper, equals({"foo": 1, "bar": 2, "baz": 3, "bang": 4, "qux": 6}));
});
test("remove()", () {
@@ -108,14 +114,16 @@
});
test("toString()", () {
- expect(wrapper.toString(), allOf([
- startsWith("{"),
- contains("foo: 1"),
- contains("bar: 2"),
- contains("baz: 3"),
- contains("bang: 4"),
- endsWith("}")
- ]));
+ expect(
+ wrapper.toString(),
+ allOf([
+ startsWith("{"),
+ contains("foo: 1"),
+ contains("bar: 2"),
+ contains("baz: 3"),
+ contains("bang: 4"),
+ endsWith("}")
+ ]));
});
});
@@ -203,14 +211,16 @@
});
test("toString()", () {
- expect(wrapper.toString(), allOf([
- startsWith("{"),
- contains("1: 1"),
- contains("2: 2"),
- contains("3: 3"),
- contains("4: 4"),
- endsWith("}")
- ]));
+ expect(
+ wrapper.toString(),
+ allOf([
+ startsWith("{"),
+ contains("1: 1"),
+ contains("2: 2"),
+ contains("3: 3"),
+ contains("4: 4"),
+ endsWith("}")
+ ]));
});
});
}, skip: "Re-enable this when test can run DDC (test#414).");
@@ -303,12 +313,14 @@
});
test("toString()", () {
- expect(wrapper.toString(), allOf([
- startsWith("{"),
- contains("foo: bar"),
- contains("baz: bang"),
- endsWith("}")
- ]));
+ expect(
+ wrapper.toString(),
+ allOf([
+ startsWith("{"),
+ contains("foo: bar"),
+ contains("baz: bang"),
+ endsWith("}")
+ ]));
});
});
}, skip: "Re-enable this when test can run DDC (test#414).");
diff --git a/test/typed_wrapper/queue_test.dart b/test/typed_wrapper/queue_test.dart
index 4eb68b3..256280d 100644
--- a/test/typed_wrapper/queue_test.dart
+++ b/test/typed_wrapper/queue_test.dart
@@ -14,8 +14,8 @@
var wrapper;
var emptyWrapper;
setUp(() {
- wrapper = DelegatingQueue.typed/*<int>*/(
- new Queue<Object>.from([1, 2, 3, 4, 5]));
+ wrapper = DelegatingQueue
+ .typed/*<int>*/(new Queue<Object>.from([1, 2, 3, 4, 5]));
emptyWrapper = DelegatingQueue.typed/*<int>*/(new Queue<Object>());
});
diff --git a/test/typed_wrapper/set_test.dart b/test/typed_wrapper/set_test.dart
index 7667442..fdbbf8e 100644
--- a/test/typed_wrapper/set_test.dart
+++ b/test/typed_wrapper/set_test.dart
@@ -11,8 +11,8 @@
group("with valid types, forwards", () {
var wrapper;
setUp(() {
- wrapper = DelegatingSet.typed/*<int>*/(
- new Set<Object>.from([1, 2, 3, 4, 5]));
+ wrapper =
+ DelegatingSet.typed/*<int>*/(new Set<Object>.from([1, 2, 3, 4, 5]));
});
test("add()", () {
diff --git a/test/unmodifiable_collection_test.dart b/test/unmodifiable_collection_test.dart
index cdb5101..91ad8ad 100644
--- a/test/unmodifiable_collection_test.dart
+++ b/test/unmodifiable_collection_test.dart
@@ -94,8 +94,8 @@
});
test("$name - expand", () {
- expect(wrapped.expand((x) => [x, x]),
- equals(original.expand((x) => [x, x])));
+ expect(
+ wrapped.expand((x) => [x, x]), equals(original.expand((x) => [x, x])));
});
test("$name - first", () {
@@ -111,21 +111,25 @@
expect(() => wrapped.firstWhere((_) => true), throws);
} else {
expect(wrapped.firstWhere((_) => true),
- equals(original.firstWhere((_) => true)));
+ equals(original.firstWhere((_) => true)));
}
expect(() => wrapped.firstWhere((_) => false), throws);
});
test("$name - fold", () {
expect(wrapped.fold(0, (x, y) => x + y),
- equals(original.fold(0, (x, y) => x + y)));
+ equals(original.fold(0, (x, y) => x + y)));
});
test("$name - forEach", () {
int wrapCtr = 0;
int origCtr = 0;
- wrapped.forEach((x) { wrapCtr += x; });
- original.forEach((x) { origCtr += x; });
+ wrapped.forEach((x) {
+ wrapCtr += x;
+ });
+ original.forEach((x) {
+ origCtr += x;
+ });
expect(wrapCtr, equals(origCtr));
});
@@ -165,7 +169,7 @@
expect(() => wrapped.lastWhere((_) => true), throws);
} else {
expect(wrapped.lastWhere((_) => true),
- equals(original.lastWhere((_) => true)));
+ equals(original.lastWhere((_) => true)));
}
expect(() => wrapped.lastWhere((_) => false), throws);
});
@@ -175,8 +179,7 @@
});
test("$name - map", () {
- expect(wrapped.map((x) => "[$x]"),
- equals(original.map((x) => "[$x]")));
+ expect(wrapped.map((x) => "[$x]"), equals(original.map((x) => "[$x]")));
});
test("$name - reduce", () {
@@ -184,7 +187,7 @@
expect(() => wrapped.reduce((x, y) => x + y), throws);
} else {
expect(wrapped.reduce((x, y) => x + y),
- equals(original.reduce((x, y) => x + y)));
+ equals(original.reduce((x, y) => x + y)));
}
});
@@ -201,7 +204,7 @@
expect(() => wrapped.singleWhere((_) => true), throws);
} else {
expect(wrapped.singleWhere((_) => true),
- equals(original.singleWhere((_) => true)));
+ equals(original.singleWhere((_) => true)));
}
expect(() => wrapped.singleWhere((_) => false), throws);
});
@@ -214,11 +217,11 @@
test("$name - skipWhile", () {
expect(wrapped.skipWhile((x) => true),
- orderedEquals(original.skipWhile((x) => true)));
+ orderedEquals(original.skipWhile((x) => true)));
expect(wrapped.skipWhile((x) => false),
- orderedEquals(original.skipWhile((x) => false)));
+ orderedEquals(original.skipWhile((x) => false)));
expect(wrapped.skipWhile((x) => x != 42),
- orderedEquals(original.skipWhile((x) => x != 42)));
+ orderedEquals(original.skipWhile((x) => x != 42)));
});
test("$name - take", () {
@@ -229,17 +232,17 @@
test("$name - takeWhile", () {
expect(wrapped.takeWhile((x) => true),
- orderedEquals(original.takeWhile((x) => true)));
+ orderedEquals(original.takeWhile((x) => true)));
expect(wrapped.takeWhile((x) => false),
- orderedEquals(original.takeWhile((x) => false)));
+ orderedEquals(original.takeWhile((x) => false)));
expect(wrapped.takeWhile((x) => x != 42),
- orderedEquals(original.takeWhile((x) => x != 42)));
+ orderedEquals(original.takeWhile((x) => x != 42)));
});
test("$name - toList", () {
expect(wrapped.toList(), orderedEquals(original.toList()));
expect(wrapped.toList(growable: false),
- orderedEquals(original.toList(growable: false)));
+ orderedEquals(original.toList(growable: false)));
});
test("$name - toSet", () {
@@ -247,12 +250,12 @@
});
test("$name - where", () {
- expect(wrapped.where((x) => true),
- orderedEquals(original.where((x) => true)));
+ expect(
+ wrapped.where((x) => true), orderedEquals(original.where((x) => true)));
expect(wrapped.where((x) => false),
- orderedEquals(original.where((x) => false)));
+ orderedEquals(original.where((x) => false)));
expect(wrapped.where((x) => x != 42),
- orderedEquals(original.where((x) => x != 42)));
+ orderedEquals(original.where((x) => x != 42)));
});
}
@@ -271,7 +274,9 @@
test("$name - []", () {
if (original.isEmpty) {
- expect(() { wrapped[0]; }, throwsRangeError);
+ expect(() {
+ wrapped[0];
+ }, throwsRangeError);
} else {
expect(wrapped[0], equals(original[0]));
}
@@ -289,17 +294,16 @@
int len = original.length;
expect(wrapped.getRange(0, len), equals(original.getRange(0, len)));
expect(wrapped.getRange(len ~/ 2, len),
- equals(original.getRange(len ~/ 2, len)));
- expect(wrapped.getRange(0, len ~/ 2),
- equals(original.getRange(0, len ~/ 2)));
+ equals(original.getRange(len ~/ 2, len)));
+ expect(
+ wrapped.getRange(0, len ~/ 2), equals(original.getRange(0, len ~/ 2)));
});
test("$name - sublist", () {
int len = original.length;
expect(wrapped.sublist(0), equals(original.sublist(0)));
expect(wrapped.sublist(len ~/ 2), equals(original.sublist(len ~/ 2)));
- expect(wrapped.sublist(0, len ~/ 2),
- equals(original.sublist(0, len ~/ 2)));
+ expect(wrapped.sublist(0, len ~/ 2), equals(original.sublist(0, len ~/ 2)));
});
test("$name - asMap", () {
@@ -318,21 +322,25 @@
});
}
- testThrows("$name - []= throws", () { wrapped[0] = 42; });
+ testThrows("$name - []= throws", () {
+ wrapped[0] = 42;
+ });
- testThrows("$name - sort throws", () { wrapped.sort(); });
+ testThrows("$name - sort throws", () {
+ wrapped.sort();
+ });
testThrows("$name - fillRange throws", () {
wrapped.fillRange(0, wrapped.length, 42);
});
testThrows("$name - setRange throws", () {
- wrapped.setRange(0, wrapped.length,
- new Iterable.generate(wrapped.length, (i) => i));
+ wrapped.setRange(
+ 0, wrapped.length, new Iterable.generate(wrapped.length, (i) => i));
});
testThrows("$name - setAll throws", () {
- wrapped.setAll(0, new Iterable.generate(wrapped.length, (i) => i));
+ wrapped.setAll(0, new Iterable.generate(wrapped.length, (i) => i));
});
}
@@ -346,7 +354,9 @@
expect(original[0], equals(originalFirst + 1));
original[0] = originalFirst;
} else {
- expect(() { wrapped[0] = 42; }, throws);
+ expect(() {
+ wrapped[0] = 42;
+ }, throws);
}
});
@@ -459,21 +469,21 @@
expect(wrapped.intersection(new Set()), isEmpty);
expect(wrapped.intersection(copy), unorderedEquals(original));
expect(wrapped.intersection(new Set.from([42])),
- new Set.from(original.contains(42) ? [42] : []));
+ new Set.from(original.contains(42) ? [42] : []));
});
test("$name - union", () {
expect(wrapped.union(new Set()), unorderedEquals(original));
expect(wrapped.union(copy), unorderedEquals(original));
expect(wrapped.union(new Set.from([42])),
- equals(original.union(new Set.from([42]))));
+ equals(original.union(new Set.from([42]))));
});
test("$name - difference", () {
expect(wrapped.difference(new Set()), unorderedEquals(original));
expect(wrapped.difference(copy), isEmpty);
expect(wrapped.difference(new Set.from([42])),
- equals(original.difference(new Set.from([42]))));
+ equals(original.difference(new Set.from([42]))));
});
}
@@ -560,8 +570,12 @@
test("$name forEach", () {
int origCnt = 0;
int wrapCnt = 0;
- wrapped.forEach((k, v) { wrapCnt += 1 << k + 3 * v; });
- original.forEach((k, v) { origCnt += 1 << k + 3 * v; });
+ wrapped.forEach((k, v) {
+ wrapCnt += 1 << k + 3 * v;
+ });
+ original.forEach((k, v) {
+ origCnt += 1 << k + 3 * v;
+ });
expect(wrapCnt, equals(origCnt));
});
@@ -585,27 +599,27 @@
});
}
- testThrows("$name operator[]= throws", () {
- wrapped[0] = 42;
- });
+ testThrows("$name operator[]= throws", () {
+ wrapped[0] = 42;
+ });
- testThrows("$name putIfAbsent throws", () {
- wrapped.putIfAbsent(0, () => 42);
- });
+ testThrows("$name putIfAbsent throws", () {
+ wrapped.putIfAbsent(0, () => 42);
+ });
- testThrows("$name addAll throws", () {
- wrapped.addAll(new Map()..[42] = 42);
- });
+ testThrows("$name addAll throws", () {
+ wrapped.addAll(new Map()..[42] = 42);
+ });
- testThrows("$name addAll empty throws", () {
- wrapped.addAll(new Map());
- });
+ testThrows("$name addAll empty throws", () {
+ wrapped.addAll(new Map());
+ });
- testThrows("$name remove throws", () {
- wrapped.remove(0);
- });
+ testThrows("$name remove throws", () {
+ wrapped.remove(0);
+ });
- testThrows("$name clear throws", () {
- wrapped.clear();
- });
+ testThrows("$name clear throws", () {
+ wrapped.clear();
+ });
}
diff --git a/test/wrapper_test.dart b/test/wrapper_test.dart
index e488945..df26c87 100644
--- a/test/wrapper_test.dart
+++ b/test/wrapper_test.dart
@@ -33,14 +33,14 @@
var equals;
noSuchMethod(Invocation m) => new _Equals(equals = getWrappedObject((m2) {
- testInvocations(m, m2);
- }));
+ testInvocations(m, m2);
+ }));
// dartanalyzer complains if this method is named `toString()`, since, if it
// truly overrides Object's `toString()`, it should return a String.
asString() => new _Equals(equals = getWrappedObject((m2) {
- testInvocations(TO_STRING_INVOCATION, m2);
- }));
+ testInvocations(TO_STRING_INVOCATION, m2);
+ }));
}
// An object with a field called "equals", only introduced into the
@@ -58,10 +58,8 @@
final List positionalArguments;
final Map<Symbol, dynamic> namedArguments;
final int _type;
- const SyntheticInvocation(this.memberName,
- this.positionalArguments,
- this.namedArguments,
- this._type);
+ const SyntheticInvocation(this.memberName, this.positionalArguments,
+ this.namedArguments, this._type);
bool get isMethod => _type == METHOD;
bool get isGetter => _type == GETTER;
@@ -79,7 +77,7 @@
}
const TO_STRING_INVOCATION = const SyntheticInvocation(
- #toString, const[], const{}, SyntheticInvocation.METHOD);
+ #toString, const [], const {}, SyntheticInvocation.METHOD);
// LikeNSM, but has types Iterable, Set and List to allow it as
// argument to DelegatingIterable/Set/List.
@@ -148,8 +146,10 @@
// expectation (which doesn't have the interface implemented or
// its default values).
expect.firstWhere(func1, orElse: null).equals.firstWhere(func1);
- expect.firstWhere(func1, orElse: func0).equals.
- firstWhere(func1, orElse: func0);
+ expect
+ .firstWhere(func1, orElse: func0)
+ .equals
+ .firstWhere(func1, orElse: func0);
expect.fold(null, func2).equals.fold(null, func2);
expect.forEach(func1).equals.forEach(func1);
expect.isEmpty.equals.isEmpty;
@@ -159,8 +159,10 @@
expect.join("X").equals.join("X");
expect.last.equals.last;
expect.lastWhere(func1, orElse: null).equals.lastWhere(func1);
- expect.lastWhere(func1, orElse: func0).equals.
- lastWhere(func1, orElse: func0);
+ expect
+ .lastWhere(func1, orElse: func0)
+ .equals
+ .lastWhere(func1, orElse: func0);
expect.length.equals.length;
expect.map(func1).equals.map(func1);
expect.reduce(func2).equals.reduce(func2);
@@ -336,17 +338,17 @@
test(".lastWhere", () {
expect(set.lastWhere((element) => element is String), equals("bar"));
- expect(set.lastWhere((element) => element.startsWith("f")),
- equals("foo"));
- expect(() => set.lastWhere((element) => element is int),
- throwsStateError);
+ expect(
+ set.lastWhere((element) => element.startsWith("f")), equals("foo"));
+ expect(
+ () => set.lastWhere((element) => element is int), throwsStateError);
expect(set.lastWhere((element) => element is int, orElse: () => "baz"),
equals("baz"));
});
test(".map", () {
- expect(set.map((element) => element.substring(1)),
- equals(["oo", "ar"]));
+ expect(
+ set.map((element) => element.substring(1)), equals(["oo", "ar"]));
});
test(".reduce", () {
@@ -357,8 +359,7 @@
test(".singleWhere", () {
expect(() => set.singleWhere((element) => element == "baz"),
throwsStateError);
- expect(set.singleWhere((element) => element == "foo"),
- "foo");
+ expect(set.singleWhere((element) => element == "foo"), "foo");
expect(() => set.singleWhere((element) => element is String),
throwsStateError);
});
@@ -374,8 +375,7 @@
equals(["bar"]));
expect(set.skipWhile((element) => element.startsWith("z")),
equals(["foo", "bar"]));
- expect(set.skipWhile((element) => element is String),
- equals([]));
+ expect(set.skipWhile((element) => element is String), equals([]));
});
test(".take", () {
@@ -387,8 +387,7 @@
test(".takeWhile", () {
expect(set.takeWhile((element) => element.startsWith("f")),
equals(["foo"]));
- expect(set.takeWhile((element) => element.startsWith("z")),
- equals([]));
+ expect(set.takeWhile((element) => element.startsWith("z")), equals([]));
expect(set.takeWhile((element) => element is String),
equals(["foo", "bar"]));
});
@@ -405,11 +404,11 @@
});
test(".where", () {
- expect(set.where((element) => element.startsWith("f")),
- equals(["foo"]));
+ expect(
+ set.where((element) => element.startsWith("f")), equals(["foo"]));
expect(set.where((element) => element.startsWith("z")), equals([]));
- expect(set.where((element) => element is String),
- equals(["foo", "bar"]));
+ expect(
+ set.where((element) => element is String), equals(["foo", "bar"]));
});
test(".containsAll", () {
@@ -529,8 +528,8 @@
setUp(() {
map = new Map<String, String>();
- set = new MapValueSet<String, String>(map,
- (string) => string.substring(0, 1));
+ set = new MapValueSet<String, String>(
+ map, (string) => string.substring(0, 1));
});
testTwoElementSet(() {
@@ -641,8 +640,8 @@
equals: (value1, value2) =>
value1.toLowerCase() == value2.toLowerCase(),
hashCode: (value) => value.toLowerCase().hashCode);
- set = new MapValueSet<String, String>(map,
- (string) => string.substring(0, 1));
+ set = new MapValueSet<String, String>(
+ map, (string) => string.substring(0, 1));
map["f"] = "foo";
map["B"] = "bar";