Enable and fix pedantic and dartfmt lints
diff --git a/analysis_options.yaml b/analysis_options.yaml
index d8300ef..c5a2a27 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,3 +1,4 @@
+include: package:pedantic/analysis_options.yaml
analyzer:
errors:
unused_element: error
@@ -30,7 +31,11 @@
- library_prefixes
- non_constant_identifier_names
- only_throw_errors
+ - prefer_equal_for_default_values
- prefer_final_fields
+ - prefer_generic_function_type_aliases
- prefer_is_not_empty
- slash_for_doc_comments
- type_init_formals
+ - unnecessary_const
+ - unnecessary_new
diff --git a/lib/src/algorithms.dart b/lib/src/algorithms.dart
index 0d37d64..9a9e371 100644
--- a/lib/src/algorithms.dart
+++ b/lib/src/algorithms.dart
@@ -65,7 +65,7 @@
///
/// A sub-range of a list can be shuffled by providing [start] and [end].
void shuffle(List list, [int start = 0, int end]) {
- var random = new math.Random();
+ var random = math.Random();
if (end == null) end = list.length;
int length = end - start;
while (length > 1) {
@@ -108,7 +108,7 @@
/// 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}) {
+ {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>();
@@ -151,7 +151,7 @@
/// 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)}) {
+ {int start = 0, int end, int compare(T a, T b)}) {
end ??= list.length;
compare ??= defaultCompare<T>();
@@ -171,7 +171,7 @@
int firstLength = middle - start;
int secondLength = end - middle;
// secondLength is always the same as firstLength, or one greater.
- var scratchSpace = new List<T>(secondLength);
+ var scratchSpace = List<T>(secondLength);
_mergeSort(list, compare, middle, end, scratchSpace, 0);
int firstTarget = end - firstLength;
_mergeSort(list, compare, start, middle, list, firstTarget);
diff --git a/lib/src/canonicalized_map.dart b/lib/src/canonicalized_map.dart
index 9e1d5cf..80324b2 100644
--- a/lib/src/canonicalized_map.dart
+++ b/lib/src/canonicalized_map.dart
@@ -6,9 +6,9 @@
import 'utils.dart';
-typedef C _Canonicalize<C, K>(K key);
+typedef _Canonicalize<C, K> = C Function(K key);
-typedef bool _IsValidKey(Object key);
+typedef _IsValidKey = bool Function(Object key);
/// A map whose keys are converted to canonical values of type `C`.
///
@@ -24,7 +24,7 @@
final _IsValidKey _isValidKeyFn;
- final _base = new Map<C, Pair<K, V>>();
+ final _base = Map<C, Pair<K, V>>();
/// Creates an empty canonicalized map.
///
@@ -62,16 +62,15 @@
void operator []=(K key, V value) {
if (!_isValidKey(key)) return;
- _base[_canonicalize(key)] = new Pair(key, value);
+ _base[_canonicalize(key)] = Pair(key, value);
}
void addAll(Map<K, V> other) {
other.forEach((key, value) => this[key] = value);
}
- void addEntries(Iterable<MapEntry<K, V>> entries) =>
- _base.addEntries(entries.map(
- (e) => new MapEntry(_canonicalize(e.key), new Pair(e.key, e.value))));
+ void addEntries(Iterable<MapEntry<K, V>> entries) => _base.addEntries(
+ entries.map((e) => MapEntry(_canonicalize(e.key), Pair(e.key, e.value))));
Map<K2, V2> cast<K2, V2>() => _base.cast<K2, V2>();
@@ -88,7 +87,7 @@
_base.values.any((pair) => pair.last == value);
Iterable<MapEntry<K, V>> get entries =>
- _base.entries.map((e) => new MapEntry(e.value.first, e.value.last));
+ _base.entries.map((e) => MapEntry(e.value.first, e.value.last));
void forEach(void f(K key, V value)) {
_base.forEach((key, pair) => f(pair.first, pair.last));
@@ -107,7 +106,7 @@
V putIfAbsent(K key, V ifAbsent()) {
return _base
- .putIfAbsent(_canonicalize(key), () => new Pair(key, ifAbsent()))
+ .putIfAbsent(_canonicalize(key), () => Pair(key, ifAbsent()))
.last;
}
@@ -124,12 +123,12 @@
Map<K2, V2> retype<K2, V2>() => cast<K2, V2>();
V update(K key, V update(V value), {V ifAbsent()}) => _base
- .update(_canonicalize(key), (pair) => new Pair(key, update(pair.last)),
- ifAbsent: ifAbsent == null ? null : () => new Pair(key, ifAbsent()))
+ .update(_canonicalize(key), (pair) => Pair(key, update(pair.last)),
+ ifAbsent: ifAbsent == null ? null : () => Pair(key, ifAbsent()))
.last;
- void updateAll(V update(K key, V value)) => _base.updateAll(
- (_, pair) => new Pair(pair.first, update(pair.first, pair.last)));
+ void updateAll(V update(K key, V value)) => _base
+ .updateAll((_, pair) => Pair(pair.first, update(pair.first, pair.last)));
Iterable<V> get values => _base.values.map((pair) => pair.last);
@@ -139,7 +138,7 @@
return '{...}';
}
- var result = new StringBuffer();
+ var result = StringBuffer();
try {
_toStringVisiting.add(this);
result.write('{');
diff --git a/lib/src/combined_wrappers/combined_iterable.dart b/lib/src/combined_wrappers/combined_iterable.dart
index 511876e..3df5e82 100644
--- a/lib/src/combined_wrappers/combined_iterable.dart
+++ b/lib/src/combined_wrappers/combined_iterable.dart
@@ -19,7 +19,7 @@
const CombinedIterableView(this._iterables);
Iterator<T> get iterator =>
- new _CombinedIterator<T>(_iterables.map((i) => i.iterator).iterator);
+ _CombinedIterator<T>(_iterables.map((i) => i.iterator).iterator);
// Special cased contains/isEmpty/length since many iterables have an
// efficient implementation instead of running through the entire iterator.
diff --git a/lib/src/combined_wrappers/combined_list.dart b/lib/src/combined_wrappers/combined_list.dart
index 21a68f6..593490e 100644
--- a/lib/src/combined_wrappers/combined_list.dart
+++ b/lib/src/combined_wrappers/combined_list.dart
@@ -16,7 +16,7 @@
class CombinedListView<T> extends ListBase<T>
implements UnmodifiableListView<T> {
static void _throw() {
- throw new UnsupportedError('Cannot modify an unmodifiable List');
+ throw UnsupportedError('Cannot modify an unmodifiable List');
}
/// The lists that this combines.
@@ -40,7 +40,7 @@
}
index -= list.length;
}
- throw new RangeError.index(initialIndex, this, 'index', null, length);
+ throw RangeError.index(initialIndex, this, 'index', null, length);
}
void operator []=(int index, T value) {
diff --git a/lib/src/combined_wrappers/combined_map.dart b/lib/src/combined_wrappers/combined_map.dart
index 8c2760b..aa86b5d 100644
--- a/lib/src/combined_wrappers/combined_map.dart
+++ b/lib/src/combined_wrappers/combined_map.dart
@@ -48,5 +48,5 @@
/// Unlike most [Map] implementations, modifying an individual map while
/// iterating the keys will _sometimes_ throw. This behavior may change in
/// the future.
- Iterable<K> get keys => new CombinedIterableView<K>(_maps.map((m) => m.keys));
+ Iterable<K> get keys => CombinedIterableView<K>(_maps.map((m) => m.keys));
}
diff --git a/lib/src/empty_unmodifiable_set.dart b/lib/src/empty_unmodifiable_set.dart
index 997619d..2c9ed30 100644
--- a/lib/src/empty_unmodifiable_set.dart
+++ b/lib/src/empty_unmodifiable_set.dart
@@ -12,27 +12,27 @@
class EmptyUnmodifiableSet<E> extends IterableBase<E>
implements UnmodifiableSetView<E> {
static T _throw<T>() {
- throw new UnsupportedError("Cannot modify an unmodifiable Set");
+ throw UnsupportedError("Cannot modify an unmodifiable Set");
}
- Iterator<E> get iterator => new Iterable<E>.empty().iterator;
+ Iterator<E> get iterator => Iterable<E>.empty().iterator;
int get length => 0;
const EmptyUnmodifiableSet();
- EmptyUnmodifiableSet<T> cast<T>() => new EmptyUnmodifiableSet<T>();
+ EmptyUnmodifiableSet<T> cast<T>() => EmptyUnmodifiableSet<T>();
bool contains(Object element) => false;
bool containsAll(Iterable<Object> other) => other.isEmpty;
- Iterable<E> followedBy(Iterable<E> other) => new Set.from(other);
+ Iterable<E> followedBy(Iterable<E> other) => Set.from(other);
E lookup(Object element) => null;
@deprecated
- EmptyUnmodifiableSet<T> retype<T>() => new EmptyUnmodifiableSet<T>();
+ EmptyUnmodifiableSet<T> retype<T>() => EmptyUnmodifiableSet<T>();
E singleWhere(bool test(E element), {E orElse()}) => super.singleWhere(test);
- Iterable<T> whereType<T>() => new EmptyUnmodifiableSet<T>();
- Set<E> toSet() => new Set();
- Set<E> union(Set<E> other) => new Set.from(other);
- Set<E> intersection(Set<Object> other) => new Set();
- Set<E> difference(Set<Object> other) => new Set();
+ Iterable<T> whereType<T>() => EmptyUnmodifiableSet<T>();
+ Set<E> toSet() => Set();
+ Set<E> union(Set<E> other) => Set.from(other);
+ Set<E> intersection(Set<Object> other) => Set();
+ Set<E> difference(Set<Object> other) => Set();
bool add(E value) => _throw();
void addAll(Iterable<E> elements) => _throw();
diff --git a/lib/src/equality.dart b/lib/src/equality.dart
index 855503e..5f4038a 100644
--- a/lib/src/equality.dart
+++ b/lib/src/equality.dart
@@ -30,7 +30,7 @@
bool isValidKey(Object o);
}
-typedef F _GetKey<E, F>(E object);
+typedef _GetKey<E, F> = F Function(E object);
/// Equality of objects based on derived values.
///
@@ -197,7 +197,7 @@
bool equals(T elements1, T elements2) {
if (identical(elements1, elements2)) return true;
if (elements1 == null || elements2 == null) return false;
- HashMap<E, int> counts = new HashMap(
+ HashMap<E, int> counts = HashMap(
equals: _elementEquality.equals,
hashCode: _elementEquality.hash,
isValidKey: _elementEquality.isValidKey);
@@ -296,8 +296,8 @@
final Equality<K> _keyEquality;
final Equality<V> _valueEquality;
const MapEquality(
- {Equality<K> keys: const DefaultEquality(),
- Equality<V> values: const DefaultEquality()})
+ {Equality<K> keys = const DefaultEquality(),
+ Equality<V> values = const DefaultEquality()})
: _keyEquality = keys,
_valueEquality = values;
@@ -306,15 +306,15 @@
if (map1 == null || map2 == null) return false;
int length = map1.length;
if (length != map2.length) return false;
- Map<_MapEntry, int> equalElementCounts = new HashMap();
+ Map<_MapEntry, int> equalElementCounts = HashMap();
for (K key in map1.keys) {
- _MapEntry entry = new _MapEntry(this, key, map1[key]);
+ _MapEntry entry = _MapEntry(this, key, map1[key]);
int count = equalElementCounts[entry];
if (count == null) count = 0;
equalElementCounts[entry] = count + 1;
}
for (K key in map2.keys) {
- _MapEntry entry = new _MapEntry(this, key, map2[key]);
+ _MapEntry entry = _MapEntry(this, key, map2[key]);
int count = equalElementCounts[entry];
if (count == null || count == 0) return false;
equalElementCounts[entry] = count - 1;
@@ -413,35 +413,33 @@
bool equals(e1, e2) {
if (e1 is Set) {
- return e2 is Set && new SetEquality(this).equals(e1, e2);
+ return e2 is Set && SetEquality(this).equals(e1, e2);
}
if (e1 is Map) {
- return e2 is Map &&
- new MapEquality(keys: this, values: this).equals(e1, e2);
+ return e2 is Map && MapEquality(keys: this, values: this).equals(e1, e2);
}
if (!_unordered) {
if (e1 is List) {
- return e2 is List && new ListEquality(this).equals(e1, e2);
+ return e2 is List && ListEquality(this).equals(e1, e2);
}
if (e1 is Iterable) {
- return e2 is Iterable && new IterableEquality(this).equals(e1, e2);
+ return e2 is Iterable && IterableEquality(this).equals(e1, e2);
}
} else if (e1 is Iterable) {
if (e1 is List != e2 is List) return false;
- return e2 is Iterable &&
- new UnorderedIterableEquality(this).equals(e1, e2);
+ return e2 is Iterable && UnorderedIterableEquality(this).equals(e1, e2);
}
return _base.equals(e1, e2);
}
int hash(Object o) {
- if (o is Set) return new SetEquality(this).hash(o);
- if (o is Map) return new MapEquality(keys: this, values: this).hash(o);
+ if (o is Set) return SetEquality(this).hash(o);
+ if (o is Map) return MapEquality(keys: this, values: this).hash(o);
if (!_unordered) {
- if (o is List) return new ListEquality(this).hash(o);
- if (o is Iterable) return new IterableEquality(this).hash(o);
+ if (o is List) return ListEquality(this).hash(o);
+ if (o is Iterable) return IterableEquality(this).hash(o);
} else if (o is Iterable) {
- return new UnorderedIterableEquality(this).hash(o);
+ return UnorderedIterableEquality(this).hash(o);
}
return _base.hash(o);
}
diff --git a/lib/src/equality_map.dart b/lib/src/equality_map.dart
index 14f074c..542977f 100644
--- a/lib/src/equality_map.dart
+++ b/lib/src/equality_map.dart
@@ -11,7 +11,7 @@
class EqualityMap<K, V> extends DelegatingMap<K, V> {
/// Creates a map with equality based on [equality].
EqualityMap(Equality<K> equality)
- : super(new LinkedHashMap(
+ : super(LinkedHashMap(
equals: equality.equals,
hashCode: equality.hash,
isValidKey: equality.isValidKey));
@@ -22,7 +22,7 @@
/// If [other] has multiple keys that are equivalent according to [equality],
/// the last one reached during iteration takes precedence.
EqualityMap.from(Equality<K> equality, Map<K, V> other)
- : super(new LinkedHashMap(
+ : super(LinkedHashMap(
equals: equality.equals,
hashCode: equality.hash,
isValidKey: equality.isValidKey)) {
diff --git a/lib/src/equality_set.dart b/lib/src/equality_set.dart
index f4abec6..8edbba5 100644
--- a/lib/src/equality_set.dart
+++ b/lib/src/equality_set.dart
@@ -11,7 +11,7 @@
class EqualitySet<E> extends DelegatingSet<E> {
/// Creates a set with equality based on [equality].
EqualitySet(Equality<E> equality)
- : super(new LinkedHashSet(
+ : super(LinkedHashSet(
equals: equality.equals,
hashCode: equality.hash,
isValidKey: equality.isValidKey));
@@ -22,7 +22,7 @@
/// If [other] has multiple values that are equivalent according to
/// [equality], the first one reached during iteration takes precedence.
EqualitySet.from(Equality<E> equality, Iterable<E> other)
- : super(new LinkedHashSet(
+ : super(LinkedHashSet(
equals: equality.equals,
hashCode: equality.hash,
isValidKey: equality.isValidKey)) {
diff --git a/lib/src/functions.dart b/lib/src/functions.dart
index b4ff9a9..83e0493 100644
--- a/lib/src/functions.dart
+++ b/lib/src/functions.dart
@@ -32,7 +32,7 @@
/// 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 = Map<K, V>.from(map1);
if (value == null) return result..addAll(map2);
map2.forEach((key, mapValue) {
@@ -118,7 +118,7 @@
// [Warshall's algorithm]: https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm#Applications_and_generalizations.
var result = <T, Set<T>>{};
graph.forEach((vertex, edges) {
- result[vertex] = new Set<T>.from(edges);
+ result[vertex] = Set<T>.from(edges);
});
// Lists are faster to iterate than maps, so we create a list since we're
@@ -160,9 +160,9 @@
// The order of these doesn't matter, so we use un-linked implementations to
// avoid unnecessary overhead.
- var indices = new HashMap<T, int>();
- var lowLinks = new HashMap<T, int>();
- var onStack = new HashSet<T>();
+ var indices = HashMap<T, int>();
+ var lowLinks = HashMap<T, int>();
+ var onStack = HashSet<T>();
strongConnect(T vertex) {
indices[vertex] = index;
@@ -182,7 +182,7 @@
}
if (lowLinks[vertex] == indices[vertex]) {
- var component = new Set<T>();
+ var component = Set<T>();
T neighbor;
do {
neighbor = stack.removeLast();
diff --git a/lib/src/iterable_zip.dart b/lib/src/iterable_zip.dart
index b983437..c2de80c 100644
--- a/lib/src/iterable_zip.dart
+++ b/lib/src/iterable_zip.dart
@@ -23,7 +23,7 @@
Iterator<List<T>> get iterator {
var iterators = _iterables.map((x) => x.iterator).toList(growable: false);
// TODO(lrn): Return an empty iterator directly if iterators is empty?
- return new _IteratorZip<T>(iterators);
+ return _IteratorZip<T>(iterators);
}
}
@@ -41,7 +41,7 @@
return false;
}
}
- _current = new List(_iterators.length);
+ _current = List(_iterators.length);
for (int i = 0; i < _iterators.length; i++) {
_current[i] = _iterators[i].current;
}
diff --git a/lib/src/priority_queue.dart b/lib/src/priority_queue.dart
index 89c3128..ec2478b 100644
--- a/lib/src/priority_queue.dart
+++ b/lib/src/priority_queue.dart
@@ -128,7 +128,7 @@
final Comparator<E> comparison;
/// List implementation of a heap.
- List<E> _queue = new List<E>(_INITIAL_CAPACITY);
+ List<E> _queue = List<E>(_INITIAL_CAPACITY);
/// Number of elements in queue.
///
@@ -167,7 +167,7 @@
}
E get first {
- if (_length == 0) throw new StateError("No such element");
+ if (_length == 0) throw StateError("No such element");
return _queue[0];
}
@@ -201,7 +201,7 @@
}
E removeFirst() {
- if (_length == 0) throw new StateError("No such element");
+ if (_length == 0) throw StateError("No such element");
E result = _queue[0];
E last = _removeLast();
if (_length > 0) {
@@ -211,14 +211,14 @@
}
List<E> toList() {
- List<E> list = new List<E>()..length = _length;
+ List<E> list = List<E>()..length = _length;
list.setRange(0, _length, _queue);
list.sort(comparison);
return list;
}
Set<E> toSet() {
- Set<E> set = new SplayTreeSet<E>(comparison);
+ Set<E> set = SplayTreeSet<E>(comparison);
for (int i = 0; i < _length; i++) {
set.add(_queue[i]);
}
@@ -353,7 +353,7 @@
void _grow() {
int newCapacity = _queue.length * 2 + 1;
if (newCapacity < _INITIAL_CAPACITY) newCapacity = _INITIAL_CAPACITY;
- List<E> newQueue = new List<E>(newCapacity);
+ List<E> newQueue = List<E>(newCapacity);
newQueue.setRange(0, _length, _queue);
_queue = newQueue;
}
diff --git a/lib/src/queue_list.dart b/lib/src/queue_list.dart
index 8b706bf..7bf307b 100644
--- a/lib/src/queue_list.dart
+++ b/lib/src/queue_list.dart
@@ -22,7 +22,7 @@
/// all elements stored in the returned are actually instance of [S],
/// then the returned instance can be used as a `QueueList<T>`.
static QueueList<T> _castFrom<S, T>(QueueList<S> source) {
- return new _CastQueueList<S, T>(source);
+ return _CastQueueList<S, T>(source);
}
static const int _INITIAL_CAPACITY = 8;
@@ -43,7 +43,7 @@
initialCapacity = _nextPowerOf2(initialCapacity);
}
assert(_isPowerOf2(initialCapacity));
- _table = new List<E>(initialCapacity);
+ _table = List<E>(initialCapacity);
}
// An internal constructor for use by _CastQueueList.
@@ -53,14 +53,14 @@
factory QueueList.from(Iterable<E> source) {
if (source is List) {
int length = source.length;
- QueueList<E> queue = new QueueList(length + 1);
+ QueueList<E> queue = QueueList(length + 1);
assert(queue._table.length > length);
var sourceList = source;
queue._table.setRange(0, length, sourceList, 0);
queue._tail = length;
return queue;
} else {
- return new QueueList<E>()..addAll(source);
+ return QueueList<E>()..addAll(source);
}
}
@@ -118,7 +118,7 @@
}
E removeFirst() {
- if (_head == _tail) throw new StateError("No element");
+ if (_head == _tail) throw StateError("No element");
E result = _table[_head];
_table[_head] = null;
_head = (_head + 1) & (_table.length - 1);
@@ -126,7 +126,7 @@
}
E removeLast() {
- if (_head == _tail) throw new StateError("No element");
+ if (_head == _tail) throw StateError("No element");
_tail = (_tail - 1) & (_table.length - 1);
E result = _table[_tail];
_table[_tail] = null;
@@ -138,7 +138,7 @@
int get length => (_tail - _head) & (_table.length - 1);
set length(int value) {
- if (value < 0) throw new RangeError("Length $value may not be negative.");
+ if (value < 0) throw RangeError("Length $value may not be negative.");
int delta = value - length;
if (delta >= 0) {
@@ -162,7 +162,7 @@
E operator [](int index) {
if (index < 0 || index >= length) {
- throw new RangeError("Index $index must be in the range [0..$length).");
+ throw RangeError("Index $index must be in the range [0..$length).");
}
return _table[(_head + index) & (_table.length - 1)];
@@ -170,7 +170,7 @@
void operator []=(int index, E value) {
if (index < 0 || index >= length) {
- throw new RangeError("Index $index must be in the range [0..$length).");
+ throw RangeError("Index $index must be in the range [0..$length).");
}
_table[(_head + index) & (_table.length - 1)] = value;
@@ -207,7 +207,7 @@
/// Grow the table when full.
void _grow() {
- List<E> newTable = new List<E>(_table.length * 2);
+ List<E> newTable = List<E>(_table.length * 2);
int split = _table.length - _head;
newTable.setRange(0, split, _table, _head);
newTable.setRange(split, split + _head, _table, 0);
@@ -238,7 +238,7 @@
// expansion.
newElementCount += newElementCount >> 1;
int newCapacity = _nextPowerOf2(newElementCount);
- List<E> newTable = new List<E>(newCapacity);
+ List<E> newTable = List<E>(newCapacity);
_tail = _writeToList(newTable);
_table = newTable;
_head = 0;
diff --git a/lib/src/union_set.dart b/lib/src/union_set.dart
index 5d88b6b..35ec410 100644
--- a/lib/src/union_set.dart
+++ b/lib/src/union_set.dart
@@ -29,7 +29,7 @@
/// is, that they contain no elements in common. This makes many operations
/// including [length] more efficient. If the component sets turn out not to
/// be disjoint, some operations may behave inconsistently.
- UnionSet(this._sets, {bool disjoint: false}) : _disjoint = disjoint;
+ UnionSet(this._sets, {bool disjoint = false}) : _disjoint = disjoint;
/// Creates a new set that's a view of the union of all sets in [sets].
///
@@ -41,7 +41,7 @@
/// is, that they contain no elements in common. This makes many operations
/// including [length] more efficient. If the component sets turn out not to
/// be disjoint, some operations may behave inconsistently.
- UnionSet.from(Iterable<Set<E>> sets, {bool disjoint: false})
+ UnionSet.from(Iterable<Set<E>> sets, {bool disjoint = false})
: this(sets.toSet(), disjoint: disjoint);
int get length => _disjoint
@@ -60,7 +60,7 @@
/// If the sets aren't guaranteed to be disjoint, this keeps track of the
/// elements we've already emitted so that we can de-duplicate them.
Iterable<E> get _dedupIterable {
- var seen = new Set<E>();
+ var seen = Set<E>();
return _sets.expand((set) => set).where((element) {
if (seen.contains(element)) return false;
seen.add(element);
@@ -79,7 +79,7 @@
}
Set<E> toSet() {
- var result = new Set<E>();
+ var result = Set<E>();
for (var set in _sets) {
result.addAll(set);
}
diff --git a/lib/src/union_set_controller.dart b/lib/src/union_set_controller.dart
index 1d0eb74..8253f70 100644
--- a/lib/src/union_set_controller.dart
+++ b/lib/src/union_set_controller.dart
@@ -27,15 +27,15 @@
UnionSet<E> _set;
/// The sets whose union is exposed through [set].
- final _sets = new Set<Set<E>>();
+ final _sets = Set<Set<E>>();
/// Creates a set of sets that provides a view of the union of those sets.
///
/// If [disjoint] is `true`, this assumes that all component sets are
/// disjoint—that is, that they contain no elements in common. This makes
/// many operations including [length] more efficient.
- UnionSetController({bool disjoint: false}) {
- _set = new UnionSet<E>(_sets, disjoint: disjoint);
+ UnionSetController({bool disjoint = false}) {
+ _set = UnionSet<E>(_sets, disjoint: disjoint);
}
/// Adds the contents of [component] to [set].
diff --git a/lib/src/unmodifiable_wrappers.dart b/lib/src/unmodifiable_wrappers.dart
index b0b5440..0e5c28c 100644
--- a/lib/src/unmodifiable_wrappers.dart
+++ b/lib/src/unmodifiable_wrappers.dart
@@ -27,8 +27,7 @@
/// change the List's length.
abstract class NonGrowableListMixin<E> implements List<E> {
static T _throw<T>() {
- throw new UnsupportedError(
- "Cannot change the length of a fixed-length list");
+ throw UnsupportedError("Cannot change the length of a fixed-length list");
}
/// Throws an [UnsupportedError];
@@ -106,7 +105,7 @@
/// change the Set.
abstract class UnmodifiableSetMixin<E> implements Set<E> {
static T _throw<T>() {
- throw new UnsupportedError("Cannot modify an unmodifiable Set");
+ throw UnsupportedError("Cannot modify an unmodifiable Set");
}
/// Throws an [UnsupportedError];
@@ -146,7 +145,7 @@
/// change the Map.
abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> {
static T _throw<T>() {
- throw new UnsupportedError("Cannot modify an unmodifiable Map");
+ throw UnsupportedError("Cannot modify an unmodifiable Map");
}
/// Throws an [UnsupportedError];
diff --git a/lib/src/wrappers.dart b/lib/src/wrappers.dart
index f7fe578..236a2c9 100644
--- a/lib/src/wrappers.dart
+++ b/lib/src/wrappers.dart
@@ -7,7 +7,7 @@
import "unmodifiable_wrappers.dart";
-typedef K _KeyForValue<K, V>(V value);
+typedef _KeyForValue<K, V> = K Function(V value);
/// A base class for delegating iterables.
///
@@ -78,7 +78,7 @@
Iterable<E> takeWhile(bool test(E value)) => _base.takeWhile(test);
- List<E> toList({bool growable: true}) => _base.toList(growable: growable);
+ List<E> toList({bool growable = true}) => _base.toList(growable: growable);
Set<E> toSet() => _base.toSet();
@@ -166,7 +166,7 @@
}
set first(E value) {
- if (this.isEmpty) throw new RangeError.index(0, this);
+ if (this.isEmpty) throw RangeError.index(0, this);
this[0] = value;
}
@@ -186,7 +186,7 @@
}
set last(E value) {
- if (this.isEmpty) throw new RangeError.index(0, this);
+ if (this.isEmpty) throw RangeError.index(0, this);
this[this.length - 1] = value;
}
@@ -312,7 +312,7 @@
Set<E> union(Set<E> other) => _setBase.union(other);
- Set<E> toSet() => new DelegatingSet<E>(_setBase.toSet());
+ Set<E> toSet() => DelegatingSet<E>(_setBase.toSet());
}
/// A [Queue] that delegates all operations to a base queue.
@@ -521,7 +521,7 @@
/// Throws an [UnsupportedError] since there's no corresponding method for
/// [Map]s.
E lookup(Object element) =>
- throw new UnsupportedError("MapKeySet doesn't support lookup().");
+ throw UnsupportedError("MapKeySet doesn't support lookup().");
@deprecated
Set<T> retype<T>() => Set.castFrom<E, T>(this);
@@ -656,7 +656,7 @@
}
void retainAll(Iterable<Object> elements) {
- var valuesToRetain = new Set<V>.identity();
+ var valuesToRetain = Set<V>.identity();
for (var element in elements) {
if (element != null && element is! V) continue;
var key = _keyForValue(element as V);
diff --git a/pubspec.yaml b/pubspec.yaml
index 983f3f4..926b5c4 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -10,4 +10,5 @@
sdk: '>=2.0.0 <3.0.0'
dev_dependencies:
+ pedantic: ^1.0.0
test: ^1.0.0
diff --git a/test/algorithms_test.dart b/test/algorithms_test.dart
index c7f5af1..0ae0916 100644
--- a/test/algorithms_test.dart
+++ b/test/algorithms_test.dart
@@ -12,7 +12,7 @@
void testShuffle(List list) {
List copy = list.toList();
shuffle(list);
- expect(new UnorderedIterableEquality().equals(list, copy), isTrue);
+ expect(UnorderedIterableEquality().equals(list, copy), isTrue);
}
test("Shuffle 0", () {
@@ -79,25 +79,25 @@
});
test("binsearchCompare0", () {
- expect(binarySearch(<C>[], new C(2), compare: compareC), equals(-1));
+ expect(binarySearch(<C>[], C(2), compare: compareC), equals(-1));
});
test("binsearchCompare1", () {
- var l1 = [new C(5)];
- expect(binarySearch(l1, new C(2), compare: compareC), equals(-1));
- expect(binarySearch(l1, new C(5), compare: compareC), equals(0));
- expect(binarySearch(l1, new C(7), compare: compareC), equals(-1));
+ var l1 = [C(5)];
+ expect(binarySearch(l1, C(2), compare: compareC), equals(-1));
+ expect(binarySearch(l1, C(5), compare: compareC), equals(0));
+ expect(binarySearch(l1, C(7), compare: compareC), equals(-1));
});
test("binsearchCompare3", () {
- var l3 = [new C(0), new C(5), new C(10)];
- expect(binarySearch(l3, new C(-1), compare: compareC), equals(-1));
- expect(binarySearch(l3, new C(0), compare: compareC), equals(0));
- expect(binarySearch(l3, new C(2), compare: compareC), equals(-1));
- expect(binarySearch(l3, new C(5), compare: compareC), equals(1));
- expect(binarySearch(l3, new C(7), compare: compareC), equals(-1));
- expect(binarySearch(l3, new C(10), compare: compareC), equals(2));
- expect(binarySearch(l3, new C(12), compare: compareC), equals(-1));
+ var l3 = [C(0), C(5), C(10)];
+ expect(binarySearch(l3, C(-1), compare: compareC), equals(-1));
+ expect(binarySearch(l3, C(0), compare: compareC), equals(0));
+ expect(binarySearch(l3, C(2), compare: compareC), equals(-1));
+ expect(binarySearch(l3, C(5), compare: compareC), equals(1));
+ expect(binarySearch(l3, C(7), compare: compareC), equals(-1));
+ expect(binarySearch(l3, C(10), compare: compareC), equals(2));
+ expect(binarySearch(l3, C(12), compare: compareC), equals(-1));
});
test("lowerbound0", () {
@@ -126,38 +126,38 @@
});
test("lowerboundCompare0", () {
- expect(lowerBound(<C>[], new C(2), compare: compareC), equals(0));
+ expect(lowerBound(<C>[], C(2), compare: compareC), equals(0));
});
test("lowerboundCompare1", () {
- var l1 = [new C(5)];
- expect(lowerBound(l1, new C(2), compare: compareC), equals(0));
- expect(lowerBound(l1, new C(5), compare: compareC), equals(0));
- expect(lowerBound(l1, new C(7), compare: compareC), equals(1));
+ var l1 = [C(5)];
+ expect(lowerBound(l1, C(2), compare: compareC), equals(0));
+ expect(lowerBound(l1, C(5), compare: compareC), equals(0));
+ expect(lowerBound(l1, C(7), compare: compareC), equals(1));
});
test("lowerboundCompare3", () {
- var l3 = [new C(0), new C(5), new C(10)];
- expect(lowerBound(l3, new C(-1), compare: compareC), equals(0));
- expect(lowerBound(l3, new C(0), compare: compareC), equals(0));
- expect(lowerBound(l3, new C(2), compare: compareC), equals(1));
- expect(lowerBound(l3, new C(5), compare: compareC), equals(1));
- expect(lowerBound(l3, new C(7), compare: compareC), equals(2));
- expect(lowerBound(l3, new C(10), compare: compareC), equals(2));
- expect(lowerBound(l3, new C(12), compare: compareC), equals(3));
+ var l3 = [C(0), C(5), C(10)];
+ expect(lowerBound(l3, C(-1), compare: compareC), equals(0));
+ expect(lowerBound(l3, C(0), compare: compareC), equals(0));
+ expect(lowerBound(l3, C(2), compare: compareC), equals(1));
+ expect(lowerBound(l3, C(5), compare: compareC), equals(1));
+ expect(lowerBound(l3, C(7), compare: compareC), equals(2));
+ expect(lowerBound(l3, C(10), compare: compareC), equals(2));
+ expect(lowerBound(l3, C(12), compare: compareC), equals(3));
});
test("lowerboundCompareRepeat", () {
- var l1 = [new C(5), new C(5), new C(5)];
- var l2 = [new C(0), new C(5), new C(5), new C(5), new C(10)];
- expect(lowerBound(l1, new C(5), compare: compareC), equals(0));
- expect(lowerBound(l2, new C(5), compare: compareC), equals(1));
+ var l1 = [C(5), C(5), C(5)];
+ var l2 = [C(0), C(5), C(5), C(5), C(10)];
+ expect(lowerBound(l1, C(5), compare: compareC), equals(0));
+ expect(lowerBound(l2, C(5), compare: compareC), equals(1));
});
test("insertionSortRandom", () {
- Random random = new Random();
+ Random random = Random();
for (int i = 0; i < 25; i++) {
- List list = new List(i);
+ List list = List(i);
for (int j = 0; j < i; j++) {
list[j] = random.nextInt(25); // Expect some equal elements.
}
@@ -193,9 +193,9 @@
});
test("MergeSortRandom", () {
- Random random = new Random();
+ Random random = Random();
for (int i = 0; i < 250; i += 1) {
- List list = new List(i);
+ List list = List(i);
for (int j = 0; j < i; j++) {
list[j] = random.nextInt(i); // Expect some equal elements.
}
@@ -207,18 +207,18 @@
});
test("MergeSortPreservesOrder", () {
- Random random = new Random();
+ Random random = Random();
// Small case where only insertion call is called,
// larger case where the internal moving insertion sort is used
// larger cases with multiple splittings, numbers just around a power of 2.
for (int size in [8, 50, 511, 512, 513]) {
- var list = new List<OC>(size);
+ var list = List<OC>(size);
// Class OC compares using id.
// With size elements with id's in the range 0..size/4, a number of
// collisions are guaranteed. These should be sorted so that the "order"
// part of the objects are still in order.
for (int i = 0; i < size; i++) {
- list[i] = new OC(random.nextInt(size >> 2), i);
+ list[i] = OC(random.nextInt(size >> 2), i);
}
mergeSort(list);
OC prev = list[0];
@@ -255,18 +255,18 @@
test("MergeSortSpecialCases", () {
for (int size in [511, 512, 513]) {
// All equal.
- List list = new List(size);
+ List list = List(size);
for (int i = 0; i < size; i++) {
- list[i] = new OC(0, i);
+ list[i] = OC(0, i);
}
mergeSort(list);
for (int i = 0; i < size; i++) {
expect(list[i].order, equals(i));
}
// All but one equal, first.
- list[0] = new OC(1, 0);
+ list[0] = OC(1, 0);
for (int i = 1; i < size; i++) {
- list[i] = new OC(0, i);
+ list[i] = OC(0, i);
}
mergeSort(list);
for (int i = 0; i < size - 1; i++) {
@@ -276,9 +276,9 @@
// All but one equal, last.
for (int i = 0; i < size - 1; i++) {
- list[i] = new OC(0, i);
+ list[i] = OC(0, i);
}
- list[size - 1] = new OC(-1, size - 1);
+ list[size - 1] = OC(-1, size - 1);
mergeSort(list);
expect(list[0].order, equals(size - 1));
for (int i = 1; i < size; i++) {
@@ -287,7 +287,7 @@
// Reversed.
for (int i = 0; i < size; i++) {
- list[i] = new OC(size - 1 - i, i);
+ list[i] = OC(size - 1 - i, i);
}
mergeSort(list);
for (int i = 0; i < size; i++) {
diff --git a/test/canonicalized_map_test.dart b/test/canonicalized_map_test.dart
index 078e57c..4ec0054 100644
--- a/test/canonicalized_map_test.dart
+++ b/test/canonicalized_map_test.dart
@@ -10,8 +10,8 @@
CanonicalizedMap<int, String, String> map;
setUp(() {
- map = new CanonicalizedMap(int.parse,
- isValidKey: (s) => new RegExp(r"^\d+$").hasMatch(s as String));
+ map = CanonicalizedMap(int.parse,
+ isValidKey: (s) => RegExp(r"^\d+$").hasMatch(s as String));
});
test("canonicalizes keys on set and get", () {
@@ -62,7 +62,7 @@
test("canonicalizes keys for putIfAbsent", () {
map["1"] = "value";
- expect(map.putIfAbsent("01", () => throw new Exception("shouldn't run")),
+ expect(map.putIfAbsent("01", () => throw Exception("shouldn't run")),
equals("value"));
expect(map.putIfAbsent("2", () => "new value"), equals("new value"));
});
@@ -148,9 +148,9 @@
test("addEntries adds key-value pairs to the map", () {
map.addEntries([
- new MapEntry("1", "value 1"),
- new MapEntry("01", "value 01"),
- new MapEntry("2", "value 2"),
+ MapEntry("1", "value 1"),
+ MapEntry("01", "value 01"),
+ MapEntry("2", "value 2"),
]);
expect(map, {"01": "value 01", "2": "value 2"});
});
@@ -163,8 +163,8 @@
group("CanonicalizedMap builds an informative string representation", () {
var map;
setUp(() {
- map = new CanonicalizedMap<int, String, dynamic>(int.parse,
- isValidKey: (s) => new RegExp(r"^\d+$").hasMatch(s as String));
+ map = CanonicalizedMap<int, String, dynamic>(int.parse,
+ isValidKey: (s) => RegExp(r"^\d+$").hasMatch(s as String));
});
test("for an empty map", () {
@@ -191,7 +191,7 @@
group("CanonicalizedMap.from", () {
test("canonicalizes its keys", () {
- var map = new CanonicalizedMap.from(
+ var map = 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"));
@@ -199,7 +199,7 @@
});
test("uses the final value for collisions", () {
- var map = new CanonicalizedMap.from(
+ var map = 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 3301821..9fb9e39 100644
--- a/test/combined_wrapper/iterable_test.dart
+++ b/test/combined_wrapper/iterable_test.dart
@@ -6,35 +6,35 @@
import 'package:test/test.dart';
void main() {
- var iterable1 = new Iterable.generate(3);
- var iterable2 = new Iterable.generate(3, (i) => i + 3);
- var iterable3 = new Iterable.generate(3, (i) => i + 6);
+ var iterable1 = Iterable.generate(3);
+ var iterable2 = Iterable.generate(3, (i) => i + 3);
+ var iterable3 = Iterable.generate(3, (i) => i + 6);
test('should combine multiple iterables when iterating', () {
- var combined = new CombinedIterableView([iterable1, iterable2, iterable3]);
+ var combined = CombinedIterableView([iterable1, iterable2, iterable3]);
expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
});
test('should combine multiple iterables with some empty ones', () {
var combined =
- new CombinedIterableView([iterable1, [], iterable2, [], iterable3, []]);
+ CombinedIterableView([iterable1, [], iterable2, [], iterable3, []]);
expect(combined, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
});
test('should function as an empty iterable when no iterables are passed', () {
- var empty = new CombinedIterableView([]);
+ var empty = CombinedIterableView([]);
expect(empty, isEmpty);
});
test('should function as an empty iterable with all empty iterables', () {
- var empty = new CombinedIterableView([[], [], []]);
+ var empty = CombinedIterableView([[], [], []]);
expect(empty, isEmpty);
});
test('should reflect changes from the underlying iterables', () {
var list1 = [];
var list2 = [];
- var combined = new CombinedIterableView([list1, list2]);
+ var combined = CombinedIterableView([list1, list2]);
expect(combined, isEmpty);
list1.addAll([1, 2]);
list2.addAll([3, 4]);
@@ -45,7 +45,7 @@
test('should reflect changes from the iterable of iterables', () {
var iterables = <Iterable>[];
- var combined = new CombinedIterableView(iterables);
+ var combined = CombinedIterableView(iterables);
expect(combined, isEmpty);
expect(combined, hasLength(0));
diff --git a/test/combined_wrapper/list_test.dart b/test/combined_wrapper/list_test.dart
index 9e90925..5bb0cb1 100644
--- a/test/combined_wrapper/list_test.dart
+++ b/test/combined_wrapper/list_test.dart
@@ -15,20 +15,20 @@
// In every way possible this should test the same as an UnmodifiableListView.
common.testUnmodifiableList(
- concat, new CombinedListView([list1, list2, list3]), 'combineLists');
+ concat, CombinedListView([list1, list2, list3]), 'combineLists');
common.testUnmodifiableList(concat,
- new CombinedListView([list1, [], list2, [], list3, []]), 'combineLists');
+ CombinedListView([list1, [], list2, [], list3, []]), 'combineLists');
test('should function as an empty list when no lists are passed', () {
- var empty = new CombinedListView([]);
+ var empty = CombinedListView([]);
expect(empty, isEmpty);
expect(empty.length, 0);
expect(() => empty[0], throwsRangeError);
});
test('should function as an empty list when only empty lists are passed', () {
- var empty = new CombinedListView([[], [], []]);
+ var empty = CombinedListView([[], [], []]);
expect(empty, isEmpty);
expect(empty.length, 0);
expect(() => empty[0], throwsRangeError);
@@ -37,7 +37,7 @@
test('should reflect underlying changes back to the combined list', () {
var backing1 = <int>[];
var backing2 = <int>[];
- var combined = new CombinedListView([backing1, backing2]);
+ var combined = CombinedListView([backing1, backing2]);
expect(combined, isEmpty);
backing1.addAll(list1);
expect(combined, list1);
@@ -47,7 +47,7 @@
test('should reflect underlying changes from the list of lists', () {
var listOfLists = <List<int>>[];
- var combined = new CombinedListView(listOfLists);
+ var combined = CombinedListView(listOfLists);
expect(combined, isEmpty);
listOfLists.add(list1);
expect(combined, list1);
@@ -59,7 +59,7 @@
test('should reflect underlying changes with a single list', () {
var backing1 = <int>[];
- var combined = new CombinedListView([backing1]);
+ var combined = CombinedListView([backing1]);
expect(combined, isEmpty);
backing1.addAll(list1);
expect(combined, list1);
diff --git a/test/combined_wrapper/map_test.dart b/test/combined_wrapper/map_test.dart
index ecafb4b..605c0be 100644
--- a/test/combined_wrapper/map_test.dart
+++ b/test/combined_wrapper/map_test.dart
@@ -15,21 +15,19 @@
// In every way possible this should test the same as an UnmodifiableMapView.
common.testReadMap(
- concat, new CombinedMapView([map1, map2, map3]), 'CombinedMapView');
+ concat, CombinedMapView([map1, map2, map3]), 'CombinedMapView');
- common.testReadMap(
- concat,
- new CombinedMapView([map1, {}, map2, {}, map3, {}]),
+ common.testReadMap(concat, CombinedMapView([map1, {}, map2, {}, map3, {}]),
'CombinedMapView (some empty)');
test('should function as an empty map when no maps are passed', () {
- var empty = new CombinedMapView([]);
+ var empty = CombinedMapView([]);
expect(empty, isEmpty);
expect(empty.length, 0);
});
test('should function as an empty map when only empty maps are passed', () {
- var empty = new CombinedMapView([{}, {}, {}]);
+ var empty = CombinedMapView([{}, {}, {}]);
expect(empty, isEmpty);
expect(empty.length, 0);
});
@@ -37,17 +35,17 @@
test('should reflect underlying changes back to the combined map', () {
var backing1 = <int, int>{};
var backing2 = <int, int>{};
- var combined = new CombinedMapView([backing1, backing2]);
+ var combined = CombinedMapView([backing1, backing2]);
expect(combined, isEmpty);
backing1.addAll(map1);
expect(combined, map1);
backing2.addAll(map2);
- expect(combined, new Map.from(backing1)..addAll(backing2));
+ expect(combined, Map.from(backing1)..addAll(backing2));
});
test('should reflect underlying changes with a single map', () {
var backing1 = <int, int>{};
- var combined = new CombinedMapView([backing1]);
+ var combined = CombinedMapView([backing1]);
expect(combined, isEmpty);
backing1.addAll(map1);
expect(combined, map1);
diff --git a/test/comparators_test.dart b/test/comparators_test.dart
index 3df0812..6a5cce8 100644
--- a/test/comparators_test.dart
+++ b/test/comparators_test.dart
@@ -85,11 +85,9 @@
// 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) {
+ replaceNumbers(String string) => string.replaceAllMapped(RegExp(r"\d+"), (m) {
var digits = m[0];
- return new String.fromCharCodes(
- [0x30, int.parse(digits), digits.length]);
+ return String.fromCharCodes([0x30, int.parse(digits), digits.length]);
});
test("compareNatural", () {
diff --git a/test/equality_map_test.dart b/test/equality_map_test.dart
index 8225efd..64344fe 100644
--- a/test/equality_map_test.dart
+++ b/test/equality_map_test.dart
@@ -7,7 +7,7 @@
void main() {
test("uses the given equality", () {
- var map = new EqualityMap(const IterableEquality());
+ var map = EqualityMap(const IterableEquality());
expect(map, isEmpty);
map[[1, 2, 3]] = 1;
@@ -22,7 +22,7 @@
});
test("EqualityMap.from() prefers the lattermost equivalent key", () {
- var map = new EqualityMap.from(const IterableEquality(), {
+ var map = EqualityMap.from(const IterableEquality(), {
[1, 2, 3]: 1,
[2, 3, 4]: 2,
[1, 2, 3]: 3,
diff --git a/test/equality_set_test.dart b/test/equality_set_test.dart
index a326b31..a99fe1f 100644
--- a/test/equality_set_test.dart
+++ b/test/equality_set_test.dart
@@ -7,7 +7,7 @@
void main() {
test("uses the given equality", () {
- var set = new EqualitySet(const IterableEquality());
+ var set = EqualitySet(const IterableEquality());
expect(set, isEmpty);
var list1 = [1, 2, 3];
@@ -35,7 +35,7 @@
var list5 = [1, 2, 3];
var list6 = [1, 2, 3];
- var set = new EqualitySet.from(
+ var set = EqualitySet.from(
const IterableEquality(), [list1, list2, list3, list4, list5, list6]);
expect(set, contains(same(list1)));
diff --git a/test/equality_test.dart b/test/equality_test.dart
index ffc8655..2b3a229 100644
--- a/test/equality_test.dart
+++ b/test/equality_test.dart
@@ -9,7 +9,7 @@
import "package:test/test.dart";
main() {
- o(Comparable id) => new Element(id);
+ o(Comparable id) => Element(id);
// Lists that are point-wise equal, but not identical.
var list1 = [o(1), o(2), o(3), o(4), o(5)];
@@ -19,42 +19,41 @@
test("IterableEquality - List", () {
expect(const IterableEquality().equals(list1, list2), isTrue);
- Equality iterId = const IterableEquality(const IdentityEquality());
+ Equality iterId = const IterableEquality(IdentityEquality());
expect(iterId.equals(list1, list2), isFalse);
});
test("IterableEquality - LinkedSet", () {
- var l1 = new LinkedHashSet.from(list1);
- var l2 = new LinkedHashSet.from(list2);
+ var l1 = LinkedHashSet.from(list1);
+ var l2 = LinkedHashSet.from(list2);
expect(const IterableEquality().equals(l1, l2), isTrue);
- Equality iterId = const IterableEquality(const IdentityEquality());
+ Equality iterId = const IterableEquality(IdentityEquality());
expect(iterId.equals(l1, l2), isFalse);
});
test("ListEquality", () {
expect(const ListEquality().equals(list1, list2), isTrue);
- Equality listId = const ListEquality(const IdentityEquality());
+ Equality listId = const ListEquality(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(const IdentityEquality()).equals(list1, list4),
- isFalse);
+ expect(
+ const ListEquality(IdentityEquality()).equals(list1, list4), 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(const IdentityEquality()).equals(list1, list5),
- isFalse);
+ expect(
+ const ListEquality(IdentityEquality()).equals(list1, list5), isFalse);
});
test("UnorderedIterableEquality", () {
expect(const UnorderedIterableEquality().equals(list1, list3), isTrue);
- Equality uniterId =
- const UnorderedIterableEquality(const IdentityEquality());
+ Equality uniterId = const UnorderedIterableEquality(IdentityEquality());
expect(uniterId.equals(list1, list3), isFalse);
});
@@ -62,7 +61,7 @@
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())
+ const UnorderedIterableEquality(IdentityEquality())
.equals(list1, list6),
isFalse);
});
@@ -71,35 +70,33 @@
var list7 = [o(1), o(3), o(5), o(4), o(6)];
expect(const UnorderedIterableEquality().equals(list1, list7), isFalse);
expect(
- const UnorderedIterableEquality(const IdentityEquality())
+ const UnorderedIterableEquality(IdentityEquality())
.equals(list1, list7),
isFalse);
});
test("SetEquality", () {
- var set1 = new HashSet.from(list1);
- var set2 = new LinkedHashSet.from(list3);
+ var set1 = HashSet.from(list1);
+ var set2 = LinkedHashSet.from(list3);
expect(const SetEquality().equals(set1, set2), isTrue);
- Equality setId = const SetEquality(const IdentityEquality());
+ Equality setId = const SetEquality(IdentityEquality());
expect(setId.equals(set1, set2), isFalse);
});
test("SetInequality length", () {
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);
+ var set1 = HashSet.from(list1);
+ var set2 = LinkedHashSet.from(list8);
expect(const SetEquality().equals(set1, set2), isFalse);
- expect(const SetEquality(const IdentityEquality()).equals(set1, set2),
- isFalse);
+ expect(const SetEquality(IdentityEquality()).equals(set1, set2), 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);
+ var set1 = HashSet.from(list1);
+ var set2 = LinkedHashSet.from(list7);
expect(const SetEquality().equals(set1, set2), isFalse);
- expect(const SetEquality(const IdentityEquality()).equals(set1, set2),
- isFalse);
+ expect(const SetEquality(IdentityEquality()).equals(set1, set2), isFalse);
});
var map1a = {
@@ -120,21 +117,21 @@
};
var l1 = [map1a, map1b];
var l2 = [map2a, map2b];
- var s1 = new Set<Map>.from(l1);
- var s2 = new Set<Map>.from([map2b, map2a]);
+ var s1 = Set<Map>.from(l1);
+ var s2 = Set<Map>.from([map2b, map2a]);
test("RecursiveEquality", () {
- const unordered = const UnorderedIterableEquality();
+ const unordered = 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);
- const mapval = const MapEquality(values: unordered);
+ const mapval = MapEquality(values: unordered);
expect(mapval.equals(map1a, map2a), isTrue);
expect(mapval.equals(map1b, map2b), isTrue);
- const listmapval = const ListEquality(mapval);
+ const listmapval = ListEquality(mapval);
expect(listmapval.equals(l1, l2), isTrue);
- const setmapval = const SetEquality<Map>(mapval);
+ const setmapval = SetEquality<Map>(mapval);
expect(setmapval.equals(s1, s2), isTrue);
});
@@ -166,10 +163,10 @@
});
group("EqualityBy should use a derived value for ", () {
- var firstEquality = new EqualityBy<List<String>, String>((e) => e.first);
- var firstInsensitiveEquality = new EqualityBy<List<String>, String>(
+ var firstEquality = EqualityBy<List<String>, String>((e) => e.first);
+ var firstInsensitiveEquality = EqualityBy<List<String>, String>(
(e) => e.first, const CaseInsensitiveEquality());
- var firstObjectEquality = new EqualityBy<List<Object>, Object>(
+ var firstObjectEquality = EqualityBy<List<Object>, Object>(
(e) => e.first, const IterableEquality());
test("equality", () {
@@ -204,10 +201,10 @@
});
test("Equality accepts null", () {
- var ie = new IterableEquality();
- var le = new ListEquality();
- var se = new SetEquality();
- var me = new MapEquality();
+ var ie = IterableEquality();
+ var le = ListEquality();
+ var se = SetEquality();
+ var me = MapEquality();
expect(ie.equals(null, null), true);
expect(ie.equals([], null), false);
expect(ie.equals(null, []), false);
@@ -219,8 +216,8 @@
expect(le.hash(null), null.hashCode);
expect(se.equals(null, null), true);
- expect(se.equals(new Set(), null), false);
- expect(se.equals(null, new Set()), false);
+ expect(se.equals(Set(), null), false);
+ expect(se.equals(null, Set()), false);
expect(se.hash(null), null.hashCode);
expect(me.equals(null, null), true);
diff --git a/test/functions_test.dart b/test/functions_test.dart
index a1e8f08..809d486 100644
--- a/test/functions_test.dart
+++ b/test/functions_test.dart
@@ -220,7 +220,7 @@
expect(
stronglyConnectedComponents({"a": []}),
equals([
- new Set.from(["a"])
+ Set.from(["a"])
]));
});
@@ -231,8 +231,8 @@
"b": []
}),
equals([
- new Set.from(["a"]),
- new Set.from(["b"])
+ Set.from(["a"]),
+ Set.from(["b"])
]));
});
@@ -243,7 +243,7 @@
"b": ["a"]
}),
equals([
- new Set.from(["a", "b"])
+ Set.from(["a", "b"])
]));
});
@@ -261,12 +261,12 @@
// 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"])
+ Set.from(["foo"]),
+ Set.from(["bar"]),
+ Set.from(["bang"]),
+ Set.from(["zap"]),
+ Set.from(["baz"]),
+ Set.from(["qux"])
]));
});
@@ -279,7 +279,7 @@
"bang": ["foo"]
}),
equals([
- new Set.from(["foo", "bar", "baz", "bang"])
+ Set.from(["foo", "bar", "baz", "bang"])
]));
});
@@ -300,9 +300,9 @@
// 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"]),
+ Set.from(["a", "b", "e"]),
+ Set.from(["c", "d", "h"]),
+ Set.from(["f", "g"]),
]));
});
@@ -320,12 +320,12 @@
// 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"])
+ Set.from(["foo"]),
+ Set.from(["bar"]),
+ Set.from(["bang"]),
+ Set.from(["zap"]),
+ Set.from(["baz"]),
+ Set.from(["qux"])
]));
});
});
diff --git a/test/iterable_zip_test.dart b/test/iterable_zip_test.dart
index 7b6db73..75a448d 100644
--- a/test/iterable_zip_test.dart
+++ b/test/iterable_zip_test.dart
@@ -17,7 +17,7 @@
main() {
test("Basic", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
@@ -31,7 +31,7 @@
test("Uneven length 1", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3, 99, 100],
[4, 5, 6],
[7, 8, 9]
@@ -45,7 +45,7 @@
test("Uneven length 2", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[4, 5, 6, 99, 100],
[7, 8, 9]
@@ -59,7 +59,7 @@
test("Uneven length 3", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9, 99, 100]
@@ -73,7 +73,7 @@
test("Uneven length 3", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3, 98],
[4, 5, 6],
[7, 8, 9, 99, 100]
@@ -87,7 +87,7 @@
test("Empty 1", () {
expect(
- new IterableZip([
+ IterableZip([
[],
[4, 5, 6],
[7, 8, 9]
@@ -97,7 +97,7 @@
test("Empty 2", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[],
[7, 8, 9]
@@ -107,7 +107,7 @@
test("Empty 3", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[4, 5, 6],
[]
@@ -116,12 +116,12 @@
});
test("Empty source", () {
- expect(new IterableZip([]), equals([]));
+ expect(IterableZip([]), equals([]));
});
test("Single Source", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3]
]),
equals([
@@ -134,16 +134,15 @@
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()
+ Set it2 = LinkedHashSet()..add(4)..add(5)..add(6);
+ Iterable it3 = (LinkedHashMap()
..[7] = 0
..[8] = 0
..[9] = 0)
.keys;
- Iterable<Iterable> allIts =
- new Iterable.generate(3, (i) => [it1, it2, it3][i]);
+ Iterable<Iterable> allIts = Iterable.generate(3, (i) => [it1, it2, it3][i]);
expect(
- new IterableZip(allIts),
+ IterableZip(allIts),
equals([
[1, 4, 7],
[2, 5, 8],
@@ -153,7 +152,7 @@
test("Error 1", () {
expect(
- () => new IterableZip([
+ () => IterableZip([
iterError([1, 2, 3], 2),
[4, 5, 6],
[7, 8, 9]
@@ -163,7 +162,7 @@
test("Error 2", () {
expect(
- () => new IterableZip([
+ () => IterableZip([
[1, 2, 3],
iterError([4, 5, 6], 5),
[7, 8, 9]
@@ -173,7 +172,7 @@
test("Error 3", () {
expect(
- () => new IterableZip([
+ () => IterableZip([
[1, 2, 3],
[4, 5, 6],
iterError([7, 8, 9], 8)
@@ -183,7 +182,7 @@
test("Error at end", () {
expect(
- () => new IterableZip([
+ () => IterableZip([
[1, 2, 3],
iterError([4, 5, 6], 6),
[7, 8, 9]
@@ -193,7 +192,7 @@
test("Error before first end", () {
expect(
- () => new IterableZip([
+ () => IterableZip([
iterError([1, 2, 3, 4], 4),
[4, 5, 6],
[7, 8, 9]
@@ -203,7 +202,7 @@
test("Error after first end", () {
expect(
- new IterableZip([
+ IterableZip([
[1, 2, 3],
[4, 5, 6],
iterError([7, 8, 9, 10], 10)
diff --git a/test/priority_queue_test.dart b/test/priority_queue_test.dart
index 92b6d33..aefd346 100644
--- a/test/priority_queue_test.dart
+++ b/test/priority_queue_test.dart
@@ -10,33 +10,32 @@
void main() {
testDefault();
- testInt(() => new HeapPriorityQueue<int>());
- testCustom((comparator) => new HeapPriorityQueue<C>(comparator));
+ testInt(() => HeapPriorityQueue<int>());
+ testCustom((comparator) => HeapPriorityQueue<C>(comparator));
}
void testDefault() {
test('new PriorityQueue() returns a HeapPriorityQueue', () {
- expect(new PriorityQueue<int>(), new TypeMatcher<HeapPriorityQueue<int>>());
+ expect(PriorityQueue<int>(), TypeMatcher<HeapPriorityQueue<int>>());
});
- testInt(() => new PriorityQueue<int>());
- testCustom((comparator) => new PriorityQueue<C>(comparator));
+ testInt(() => PriorityQueue<int>());
+ testCustom((comparator) => PriorityQueue<C>(comparator));
}
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, List<int>.generate(count, (x) => x), count);
}
}
void testCustom(PriorityQueue<C> create(int comparator(C a, C b))) {
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));
+ List<C>.generate(count, (x) => C(x)), C(count));
testQueue("Custom:$count/compare", () => create(compare),
- new List<C>.generate(count, (x) => new C(x)), new C(count));
+ List<C>.generate(count, (x) => C(x)), C(count));
testQueue("Custom:$count/compareNeg", () => create(compareNeg),
- new List<C>.generate(count, (x) => new C(count - x)), new C(0));
+ List<C>.generate(count, (x) => C(count - x)), C(0));
}
}
diff --git a/test/queue_list_test.dart b/test/queue_list_test.dart
index 543cbae..9522a39 100644
--- a/test/queue_list_test.dart
+++ b/test/queue_list_test.dart
@@ -10,21 +10,21 @@
void main() {
group("new QueueList()", () {
test("creates an empty QueueList", () {
- expect(new QueueList(), isEmpty);
+ expect(QueueList(), isEmpty);
});
test("takes an initial capacity", () {
- expect(new QueueList(100), isEmpty);
+ expect(QueueList(100), isEmpty);
});
});
test("new QueueList.from() copies the contents of an iterable", () {
- expect(new QueueList.from([1, 2, 3].skip(1)), equals([2, 3]));
+ expect(QueueList.from([1, 2, 3].skip(1)), equals([2, 3]));
});
group("add()", () {
test("adds an element to the end of the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
queue.add(4);
expect(queue, equals([1, 2, 3, 4]));
});
@@ -38,7 +38,7 @@
group("addAll()", () {
test("adds elements to the end of the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
queue.addAll([4, 5, 6]);
expect(queue, equals([1, 2, 3, 4, 5, 6]));
});
@@ -52,7 +52,7 @@
group("addFirst()", () {
test("adds an element to the beginning of the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
queue.addFirst(0);
expect(queue, equals([0, 1, 2, 3]));
});
@@ -66,7 +66,7 @@
group("removeFirst()", () {
test("removes an element from the beginning of the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(queue.removeFirst(), equals(1));
expect(queue, equals([2, 3]));
});
@@ -86,13 +86,13 @@
});
test("throws a StateError for an empty queue", () {
- expect(new QueueList().removeFirst, throwsStateError);
+ expect(QueueList().removeFirst, throwsStateError);
});
});
group("removeLast()", () {
test("removes an element from the end of the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(queue.removeLast(), equals(3));
expect(queue, equals([1, 2]));
});
@@ -110,13 +110,13 @@
});
test("throws a StateError for an empty queue", () {
- expect(new QueueList().removeLast, throwsStateError);
+ expect(QueueList().removeLast, throwsStateError);
});
});
group("length", () {
test("returns the length of a queue", () {
- expect(new QueueList.from([1, 2, 3]).length, equals(3));
+ expect(QueueList.from([1, 2, 3]).length, equals(3));
});
test("returns the length of a queue with an internal gap", () {
@@ -130,25 +130,25 @@
group("length=", () {
test("shrinks a larger queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
queue.length = 1;
expect(queue, equals([1]));
});
test("grows a smaller queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
queue.length = 5;
expect(queue, equals([1, 2, 3, null, null]));
});
test("throws a RangeError if length is less than 0", () {
- expect(() => new QueueList().length = -1, throwsRangeError);
+ expect(() => QueueList().length = -1, throwsRangeError);
});
});
group("[]", () {
test("returns individual entries in the queue", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(queue[0], equals(1));
expect(queue[1], equals(2));
expect(queue[2], equals(3));
@@ -166,21 +166,21 @@
});
test("throws a RangeError if the index is less than 0", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(() => queue[-1], throwsRangeError);
});
test(
"throws a RangeError if the index is greater than or equal to the "
"length", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(() => queue[3], throwsRangeError);
});
});
group("[]=", () {
test("sets individual entries in the queue", () {
- var queue = new QueueList<dynamic>.from([1, 2, 3]);
+ var queue = QueueList<dynamic>.from([1, 2, 3]);
queue[0] = "a";
queue[1] = "b";
queue[2] = "c";
@@ -200,7 +200,7 @@
});
test("throws a RangeError if the index is less than 0", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(() {
queue[-1] = 0;
}, throwsRangeError);
@@ -209,7 +209,7 @@
test(
"throws a RangeError if the index is greater than or equal to the "
"length", () {
- var queue = new QueueList.from([1, 2, 3]);
+ var queue = QueueList.from([1, 2, 3]);
expect(() {
queue[3] = 4;
}, throwsRangeError);
@@ -219,7 +219,7 @@
group("throws a modification error for", () {
var queue;
setUp(() {
- queue = new QueueList.from([1, 2, 3]);
+ queue = QueueList.from([1, 2, 3]);
});
test("add", () {
@@ -254,7 +254,7 @@
});
test("cast does not throw on mutation when the type is valid", () {
- var patternQueue = new QueueList<Pattern>()..addAll(['a', 'b']);
+ var patternQueue = QueueList<Pattern>()..addAll(['a', 'b']);
var stringQueue = patternQueue.cast<String>();
stringQueue.addAll(['c', 'd']);
expect(
@@ -274,7 +274,7 @@
});
test("cast throws on mutation when the type is not valid", () {
- QueueList<Object> stringQueue = new QueueList<String>();
+ QueueList<Object> stringQueue = QueueList<String>();
var numQueue = stringQueue.cast<num>();
expect(
numQueue,
@@ -290,7 +290,7 @@
});
test("cast returns a new QueueList", () {
- var queue = new QueueList<String>();
+ var queue = QueueList<String>();
expect(queue.cast<Pattern>(), isNot(same(queue)));
});
}
@@ -300,12 +300,12 @@
QueueList atCapacity() {
// Use addAll because [new QueueList.from(List)] won't use the default initial
// capacity of 8.
- return new QueueList()..addAll([1, 2, 3, 4, 5, 6, 7]);
+ return QueueList()..addAll([1, 2, 3, 4, 5, 6, 7]);
}
/// Returns a queue whose internal tail has a lower index than its head.
QueueList withInternalGap() {
- var queue = new QueueList.from(<dynamic>[null, null, null, null, 1, 2, 3, 4]);
+ var queue = QueueList.from(<dynamic>[null, null, null, null, 1, 2, 3, 4]);
for (var i = 0; i < 4; i++) {
queue.removeFirst();
}
@@ -318,4 +318,4 @@
/// Returns a matcher that expects that a closure throws a
/// [ConcurrentModificationError].
final throwsConcurrentModificationError =
- throwsA(new TypeMatcher<ConcurrentModificationError>());
+ throwsA(TypeMatcher<ConcurrentModificationError>());
diff --git a/test/union_set_controller_test.dart b/test/union_set_controller_test.dart
index 8c561d3..ff8c95a 100644
--- a/test/union_set_controller_test.dart
+++ b/test/union_set_controller_test.dart
@@ -10,14 +10,14 @@
UnionSetController<int> controller;
Set<int> innerSet;
setUp(() {
- innerSet = new Set.from([1, 2, 3]);
- controller = new UnionSetController()..add(innerSet);
+ innerSet = Set.from([1, 2, 3]);
+ controller = UnionSetController()..add(innerSet);
});
test("exposes a union set", () {
expect(controller.set, unorderedEquals([1, 2, 3]));
- controller.add(new Set.from([3, 4, 5]));
+ controller.add(Set.from([3, 4, 5]));
expect(controller.set, unorderedEquals([1, 2, 3, 4, 5]));
controller.remove(innerSet);
@@ -27,7 +27,7 @@
test("exposes a disjoint union set", () {
expect(controller.set, unorderedEquals([1, 2, 3]));
- controller.add(new Set.from([4, 5, 6]));
+ controller.add(Set.from([4, 5, 6]));
expect(controller.set, unorderedEquals([1, 2, 3, 4, 5, 6]));
controller.remove(innerSet);
diff --git a/test/union_set_test.dart b/test/union_set_test.dart
index d0437ff..6624e5f 100644
--- a/test/union_set_test.dart
+++ b/test/union_set_test.dart
@@ -10,7 +10,7 @@
group("with an empty outer set", () {
var set;
setUp(() {
- set = new UnionSet<int>(new Set());
+ set = UnionSet<int>(Set());
});
test("length returns 0", () {
@@ -42,11 +42,11 @@
group("with multiple disjoint sets", () {
var set;
setUp(() {
- set = new UnionSet.from([
- new Set.of([1, 2]),
- new Set.of([3, 4]),
- new Set.of([5]),
- new Set()
+ set = UnionSet.from([
+ Set.of([1, 2]),
+ Set.of([3, 4]),
+ Set.of([5]),
+ Set()
], disjoint: true);
});
@@ -81,11 +81,11 @@
group("with multiple overlapping sets", () {
var set;
setUp(() {
- set = new UnionSet.from([
- new Set.of([1, 2, 3]),
- new Set.of([3, 4]),
- new Set.of([5, 1]),
- new Set()
+ set = UnionSet.from([
+ Set.of([1, 2, 3]),
+ Set.of([3, 4]),
+ Set.of([5, 1]),
+ Set()
]);
});
@@ -108,17 +108,17 @@
});
test("lookup() returns the first element in an ordered context", () {
- var duration1 = new Duration(seconds: 0);
- var duration2 = new Duration(seconds: 0);
+ var duration1 = Duration(seconds: 0);
+ var duration2 = Duration(seconds: 0);
expect(duration1, equals(duration2));
expect(duration1, isNot(same(duration2)));
- var set = new UnionSet.from([
- new Set.of([duration1]),
- new Set.of([duration2])
+ var set = UnionSet.from([
+ Set.of([duration1]),
+ Set.of([duration2])
]);
- expect(set.lookup(new Duration(seconds: 0)), same(duration1));
+ expect(set.lookup(Duration(seconds: 0)), same(duration1));
});
test("toSet() returns the union of all the sets", () {
@@ -134,10 +134,10 @@
group("after an inner set was modified", () {
var set;
setUp(() {
- var innerSet = new Set.of([3, 7]);
- set = new UnionSet.from([
- new Set.of([1, 2]),
- new Set.of([5]),
+ var innerSet = Set.of([3, 7]);
+ set = UnionSet.from([
+ Set.of([1, 2]),
+ Set.of([5]),
innerSet
]);
@@ -178,16 +178,16 @@
group("after the outer set was modified", () {
var set;
setUp(() {
- var innerSet = new Set.of([6]);
- var outerSet = new Set.of([
- new Set.of([1, 2]),
- new Set.of([5]),
+ var innerSet = Set.of([6]);
+ var outerSet = Set.of([
+ Set.of([1, 2]),
+ Set.of([5]),
innerSet
]);
- set = new UnionSet<int>(outerSet);
+ set = UnionSet<int>(outerSet);
outerSet.remove(innerSet);
- outerSet.add(new Set.of([3, 4]));
+ outerSet.add(Set.of([3, 4]));
});
test("length returns the total length", () {
diff --git a/test/unmodifiable_collection_test.dart b/test/unmodifiable_collection_test.dart
index c7b539f..dcc0f3b 100644
--- a/test/unmodifiable_collection_test.dart
+++ b/test/unmodifiable_collection_test.dart
@@ -12,39 +12,39 @@
main() {
var list = <int>[];
- testUnmodifiableList(list, new UnmodifiableListView(list), "empty");
+ testUnmodifiableList(list, UnmodifiableListView(list), "empty");
list = [42];
- testUnmodifiableList(list, new UnmodifiableListView(list), "single-42");
+ testUnmodifiableList(list, UnmodifiableListView(list), "single-42");
list = [7];
- testUnmodifiableList(list, new UnmodifiableListView(list), "single!42");
+ testUnmodifiableList(list, UnmodifiableListView(list), "single!42");
list = [1, 42, 10];
- testUnmodifiableList(list, new UnmodifiableListView(list), "three-42");
+ testUnmodifiableList(list, UnmodifiableListView(list), "three-42");
list = [1, 7, 10];
- testUnmodifiableList(list, new UnmodifiableListView(list), "three!42");
+ testUnmodifiableList(list, UnmodifiableListView(list), "three!42");
list = [];
- testNonGrowableList(list, new NonGrowableListView(list), "empty");
+ testNonGrowableList(list, NonGrowableListView(list), "empty");
list = [42];
- testNonGrowableList(list, new NonGrowableListView(list), "single-42");
+ testNonGrowableList(list, NonGrowableListView(list), "single-42");
list = [7];
- testNonGrowableList(list, new NonGrowableListView(list), "single!42");
+ testNonGrowableList(list, NonGrowableListView(list), "single!42");
list = [1, 42, 10];
- testNonGrowableList(list, new NonGrowableListView(list), "three-42");
+ testNonGrowableList(list, NonGrowableListView(list), "three-42");
list = [1, 7, 10];
- testNonGrowableList(list, new NonGrowableListView(list), "three!42");
+ testNonGrowableList(list, NonGrowableListView(list), "three!42");
- var aSet = new Set<int>();
- testUnmodifiableSet(aSet, new UnmodifiableSetView(aSet), "empty");
- aSet = new Set();
+ var aSet = Set<int>();
+ testUnmodifiableSet(aSet, UnmodifiableSetView(aSet), "empty");
+ aSet = Set();
testUnmodifiableSet(aSet, const UnmodifiableSetView.empty(), "const empty");
- aSet = new Set.of([42]);
- testUnmodifiableSet(aSet, new UnmodifiableSetView(aSet), "single-42");
- aSet = new Set.of([7]);
- testUnmodifiableSet(aSet, new UnmodifiableSetView(aSet), "single!42");
- aSet = new Set.of([1, 42, 10]);
- testUnmodifiableSet(aSet, new UnmodifiableSetView(aSet), "three-42");
- aSet = new Set.of([1, 7, 10]);
- testUnmodifiableSet(aSet, new UnmodifiableSetView(aSet), "three!42");
+ aSet = Set.of([42]);
+ testUnmodifiableSet(aSet, UnmodifiableSetView(aSet), "single-42");
+ aSet = Set.of([7]);
+ testUnmodifiableSet(aSet, UnmodifiableSetView(aSet), "single!42");
+ aSet = Set.of([1, 42, 10]);
+ testUnmodifiableSet(aSet, UnmodifiableSetView(aSet), "three-42");
+ aSet = Set.of([1, 7, 10]);
+ testUnmodifiableSet(aSet, UnmodifiableSetView(aSet), "three!42");
}
void testUnmodifiableList(List<int> original, List<int> wrapped, String name) {
@@ -312,7 +312,7 @@
}
void testNoWriteList(List<int> original, List<int> wrapped, String name) {
- var copy = new List.of(original);
+ var copy = List.of(original);
testThrows(name, thunk) {
test(name, () {
@@ -336,16 +336,16 @@
testThrows("$name - setRange throws", () {
wrapped.setRange(
- 0, wrapped.length, new Iterable.generate(wrapped.length, (i) => i));
+ 0, wrapped.length, Iterable.generate(wrapped.length, (i) => i));
});
testThrows("$name - setAll throws", () {
- wrapped.setAll(0, new Iterable.generate(wrapped.length, (i) => i));
+ wrapped.setAll(0, Iterable.generate(wrapped.length, (i) => i));
});
}
void testWriteList(List<int> original, List wrapped, String name) {
- var copy = new List.of(original);
+ var copy = List.of(original);
test("$name - []=", () {
if (original.isNotEmpty) {
@@ -361,7 +361,7 @@
});
test("$name - sort", () {
- List sortCopy = new List.of(original);
+ List sortCopy = List.of(original);
sortCopy.sort();
wrapped.sort();
expect(original, orderedEquals(sortCopy));
@@ -393,7 +393,7 @@
void testNoChangeLengthList(
List<int> original, List<int> wrapped, String name) {
- var copy = new List.of(original);
+ var copy = List.of(original);
void testThrows(String name, thunk) {
test(name, () {
@@ -457,7 +457,7 @@
}
void testReadSet(Set<int> original, Set<int> wrapped, String name) {
- var copy = new Set.of(original);
+ var copy = Set.of(original);
test("$name - containsAll", () {
expect(wrapped.containsAll(copy), isTrue);
@@ -467,24 +467,23 @@
});
test("$name - intersection", () {
- expect(wrapped.intersection(new Set()), isEmpty);
+ expect(wrapped.intersection(Set()), isEmpty);
expect(wrapped.intersection(copy), unorderedEquals(original));
- expect(wrapped.intersection(new Set.of([42])),
- new Set.of(original.contains(42) ? [42] : []));
+ expect(wrapped.intersection(Set.of([42])),
+ Set.of(original.contains(42) ? [42] : []));
});
test("$name - union", () {
- expect(wrapped.union(new Set()), unorderedEquals(original));
+ expect(wrapped.union(Set()), unorderedEquals(original));
expect(wrapped.union(copy), unorderedEquals(original));
- expect(wrapped.union(new Set.of([42])),
- equals(original.union(new Set.of([42]))));
+ expect(wrapped.union(Set.of([42])), equals(original.union(Set.of([42]))));
});
test("$name - difference", () {
- expect(wrapped.difference(new Set()), unorderedEquals(original));
+ expect(wrapped.difference(Set()), unorderedEquals(original));
expect(wrapped.difference(copy), isEmpty);
- expect(wrapped.difference(new Set.of([42])),
- equals(original.difference(new Set.of([42]))));
+ expect(wrapped.difference(Set.of([42])),
+ equals(original.difference(Set.of([42]))));
});
}
@@ -590,7 +589,7 @@
}
testNoChangeMap(Map<int, int> original, Map<int, int> wrapped, String name) {
- var copy = new Map.of(original);
+ var copy = Map.of(original);
testThrows(name, thunk) {
test(name, () {
@@ -609,11 +608,11 @@
});
testThrows("$name addAll throws", () {
- wrapped.addAll(new Map()..[42] = 42);
+ wrapped.addAll(Map()..[42] = 42);
});
testThrows("$name addAll empty throws", () {
- wrapped.addAll(new Map());
+ wrapped.addAll(Map());
});
testThrows("$name remove throws", () {
diff --git a/test/utils.dart b/test/utils.dart
index a97275e..dbeadc7 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -4,7 +4,7 @@
import "package:test/test.dart";
-final Matcher throwsCastError = throwsA(new TypeMatcher<CastError>());
+final Matcher throwsCastError = throwsA(TypeMatcher<CastError>());
/// A hack to determine whether we are running in a Dart 2 runtime.
final bool isDart2 = _isTypeArgString('');
diff --git a/test/wrapper_test.dart b/test/wrapper_test.dart
index bb8f90f..643c441 100644
--- a/test/wrapper_test.dart
+++ b/test/wrapper_test.dart
@@ -66,7 +66,7 @@
// don't override those and so the wrappers don't forward those.
}
-final toStringInvocation = new Invocation.method(#toString, const []);
+final toStringInvocation = Invocation.method(#toString, const []);
// InvocationCheckers with types Queue, Set, List or Iterable to allow them as
// argument to DelegatingIterable/Set/List/Queue.
@@ -95,38 +95,37 @@
// Expector that wraps in DelegatingIterable.
class IterableExpector<T> extends Expector implements Iterable<T> {
wrappedChecker(Invocation i) =>
- new DelegatingIterable<T>(new IterableInvocationChecker<T>(i));
+ DelegatingIterable<T>(IterableInvocationChecker<T>(i));
}
// Expector that wraps in DelegatingList.
class ListExpector<T> extends Expector implements List<T> {
wrappedChecker(Invocation i) =>
- new DelegatingList<T>(new ListInvocationChecker<T>(i));
+ DelegatingList<T>(ListInvocationChecker<T>(i));
}
// Expector that wraps in DelegatingSet.
class SetExpector<T> extends Expector implements Set<T> {
- wrappedChecker(Invocation i) =>
- new DelegatingSet<T>(new SetInvocationChecker<T>(i));
+ wrappedChecker(Invocation i) => DelegatingSet<T>(SetInvocationChecker<T>(i));
}
// Expector that wraps in DelegatingSet.
class QueueExpector<T> extends Expector implements Queue<T> {
wrappedChecker(Invocation i) =>
- new DelegatingQueue<T>(new QueueInvocationChecker<T>(i));
+ DelegatingQueue<T>(QueueInvocationChecker<T>(i));
}
// Expector that wraps in DelegatingMap.
class MapExpector<K, V> extends Expector implements Map<K, V> {
wrappedChecker(Invocation i) =>
- new DelegatingMap<K, V>(new MapInvocationChecker<K, V>(i));
+ DelegatingMap<K, V>(MapInvocationChecker<K, V>(i));
}
// Utility values to use as arguments in calls.
Null func0() => null;
Null func1(Object x) => null;
Null func2(Object x, Object y) => null;
-var val = new Object();
+var val = Object();
void main() {
testIterable(var expect) {
@@ -212,7 +211,7 @@
void testSet(var expect) {
testIterable(expect);
- Set set = new Set();
+ Set set = Set();
(expect..add(val)).equals.add(val);
(expect..addAll([val])).equals.addAll([val]);
(expect..clear()).equals.clear();
@@ -240,7 +239,7 @@
}
void testMap(var expect) {
- Map map = new Map();
+ Map map = Map();
(expect..[val]).equals[val];
(expect..[val] = val).equals[val] = val;
(expect..addAll(map)).equals.addAll(map);
@@ -393,7 +392,7 @@
});
test(".toSet", () {
- expect(set.toSet(), equals(new Set.from(["foo", "bar"])));
+ expect(set.toSet(), equals(Set.from(["foo", "bar"])));
});
test(".where", () {
@@ -411,40 +410,40 @@
});
test(".difference", () {
- expect(set.difference(new Set.from(["foo", "baz"])),
- equals(new Set.from(["bar"])));
+ expect(set.difference(Set.from(["foo", "baz"])),
+ equals(Set.from(["bar"])));
});
test(".intersection", () {
- expect(set.intersection(new Set.from(["foo", "baz"])),
- equals(new Set.from(["foo"])));
+ expect(set.intersection(Set.from(["foo", "baz"])),
+ equals(Set.from(["foo"])));
});
test(".union", () {
- expect(set.union(new Set.from(["foo", "baz"])),
- equals(new Set.from(["foo", "bar", "baz"])));
+ expect(set.union(Set.from(["foo", "baz"])),
+ equals(Set.from(["foo", "bar", "baz"])));
});
});
}
test("Iterable", () {
- testIterable(new IterableExpector());
+ testIterable(IterableExpector());
});
test("List", () {
- testList(new ListExpector());
+ testList(ListExpector());
});
test("Set", () {
- testSet(new SetExpector());
+ testSet(SetExpector());
});
test("Queue", () {
- testQueue(new QueueExpector());
+ testQueue(QueueExpector());
});
test("Map", () {
- testMap(new MapExpector());
+ testMap(MapExpector());
});
group("MapKeySet", () {
@@ -452,8 +451,8 @@
Set<String> set;
setUp(() {
- map = new Map<String, int>();
- set = new MapKeySet<String>(map);
+ map = Map<String, int>();
+ set = MapKeySet<String>(map);
});
testTwoElementSet(() {
@@ -520,9 +519,9 @@
Set<String> set;
setUp(() {
- map = new Map<String, String>();
- set = new MapValueSet<String, String>(
- map, (string) => string.substring(0, 1));
+ map = Map<String, String>();
+ set =
+ MapValueSet<String, String>(map, (string) => string.substring(0, 1));
});
testTwoElementSet(() {
@@ -629,12 +628,12 @@
});
test(".retainAll respects an unusual notion of equality", () {
- map = new HashMap<String, String>(
+ map = HashMap<String, String>(
equals: (value1, value2) =>
value1.toLowerCase() == value2.toLowerCase(),
hashCode: (value) => value.toLowerCase().hashCode);
- set = new MapValueSet<String, String>(
- map, (string) => string.substring(0, 1));
+ set =
+ MapValueSet<String, String>(map, (string) => string.substring(0, 1));
map["f"] = "foo";
map["B"] = "bar";