fix pedantic lints
diff --git a/lib/src/change_notifier.dart b/lib/src/change_notifier.dart
index 2aeaf63..a093d01 100644
--- a/lib/src/change_notifier.dart
+++ b/lib/src/change_notifier.dart
@@ -23,7 +23,7 @@
/// Changes should produced in order, if significant.
@override
Stream<List<C>> get changes {
- return (_changes ??= new StreamController<List<C>>.broadcast(
+ return (_changes ??= StreamController<List<C>>.broadcast(
sync: true,
onListen: observed,
onCancel: unobserved,
@@ -96,7 +96,7 @@
T oldValue,
T newValue,
) {
- throw new UnsupportedError('Not supported by ChangeNotifier');
+ throw UnsupportedError('Not supported by ChangeNotifier');
}
}
@@ -117,7 +117,7 @@
) {
if (hasObservers && oldValue != newValue) {
notifyChange(
- new PropertyChangeRecord<T>(
+ PropertyChangeRecord<T>(
this,
field,
oldValue,
diff --git a/lib/src/differs/list_differ.dart b/lib/src/differs/list_differ.dart
index c59830e..712d065 100644
--- a/lib/src/differs/list_differ.dart
+++ b/lib/src/differs/list_differ.dart
@@ -59,11 +59,11 @@
// 'Deletion' columns.
final rowCount = oldEnd - oldStart + 1;
final columnCount = currentEnd - currentStart + 1;
- final distances = new List<List<int>>(rowCount);
+ final distances = List<List<int>>(rowCount);
// 'Addition' rows. Initialize null column.
for (var i = 0; i < rowCount; i++) {
- distances[i] = new List<int>(columnCount);
+ distances[i] = List<int>(columnCount);
distances[i][0] = i;
}
@@ -212,7 +212,7 @@
if (currentStart == currentEnd) {
final spliceRemoved = old.sublist(oldStart, oldEnd);
return [
- new ListChangeRecord<E>.remove(
+ ListChangeRecord<E>.remove(
current,
currentStart,
spliceRemoved,
@@ -221,7 +221,7 @@
}
if (oldStart == oldEnd) {
return [
- new ListChangeRecord<E>.add(
+ ListChangeRecord<E>.add(
current,
currentStart,
currentEnd - currentStart,
@@ -259,7 +259,7 @@
switch (op) {
case _Edit.leave:
if (hasSplice()) {
- splices.add(new ListChangeRecord<E>(
+ splices.add(ListChangeRecord<E>(
current,
spliceIndex,
removed: spliceRemovals,
@@ -296,7 +296,7 @@
}
}
if (hasSplice()) {
- splices.add(new ListChangeRecord<E>(
+ splices.add(ListChangeRecord<E>(
current,
spliceIndex,
removed: spliceRemovals,
@@ -304,7 +304,7 @@
));
}
assert(() {
- splices = new List<ListChangeRecord<E>>.unmodifiable(splices);
+ splices = List<ListChangeRecord<E>>.unmodifiable(splices);
return true;
}());
return splices;
@@ -331,7 +331,7 @@
// - then continues and updates the subsequent splices with any offset diff.
for (var i = 0; i < splices.length; i++) {
var current = splices[i];
- current = splices[i] = new ListChangeRecord<E>(
+ current = splices[i] = ListChangeRecord<E>(
current.object,
current.index + insertionOffset,
removed: current.removed,
@@ -386,7 +386,7 @@
inserted = true;
splices.insert(
i,
- new ListChangeRecord<E>(
+ ListChangeRecord<E>(
record.object,
spliceIndex,
removed: spliceRemoved,
@@ -395,7 +395,7 @@
);
i++;
final offset = spliceAdded - spliceRemoved.length;
- current = splices[i] = new ListChangeRecord<E>(
+ current = splices[i] = ListChangeRecord<E>(
current.object,
current.index + offset,
removed: current.removed,
@@ -405,7 +405,7 @@
}
}
if (!inserted) {
- splices.add(new ListChangeRecord<E>(
+ splices.add(ListChangeRecord<E>(
record.object,
spliceIndex,
removed: spliceRemoved,
@@ -442,7 +442,7 @@
List<ListChangeRecord<E>> projectListSplices<E>(
List<E> list, List<ListChangeRecord<E>> records,
[Equality<E> equality]) {
- equality ??= new DefaultEquality<E>();
+ equality ??= DefaultEquality<E>();
if (records.length <= 1) return records;
final splices = <ListChangeRecord<E>>[];
final initialSplices = _createInitialSplices(list, records);
diff --git a/lib/src/differs/map_differ.dart b/lib/src/differs/map_differ.dart
index 6f01fb7..46ffbd7 100644
--- a/lib/src/differs/map_differ.dart
+++ b/lib/src/differs/map_differ.dart
@@ -23,14 +23,14 @@
oldValue.forEach((oldK, oldV) {
final newV = newValue[oldK];
if (newV == null && !newValue.containsKey(oldK)) {
- changes.add(new MapChangeRecord<K, V>.remove(oldK, oldV));
+ changes.add(MapChangeRecord<K, V>.remove(oldK, oldV));
} else if (newV != oldV) {
- changes.add(new MapChangeRecord<K, V>(oldK, oldV, newV));
+ changes.add(MapChangeRecord<K, V>(oldK, oldV, newV));
}
});
newValue.forEach((newK, newV) {
if (!oldValue.containsKey(newK)) {
- changes.add(new MapChangeRecord<K, V>.insert(newK, newV));
+ changes.add(MapChangeRecord<K, V>.insert(newK, newV));
}
});
return freezeInDevMode(changes);
diff --git a/lib/src/internal.dart b/lib/src/internal.dart
index d600f50..ba59783 100644
--- a/lib/src/internal.dart
+++ b/lib/src/internal.dart
@@ -5,7 +5,7 @@
List<E> freezeInDevMode<E>(List<E> list) {
if (list == null) return const [];
assert(() {
- list = new List<E>.unmodifiable(list);
+ list = List<E>.unmodifiable(list);
return true;
}());
return list;
diff --git a/lib/src/observable.dart b/lib/src/observable.dart
index edc536b..2f6e0f7 100644
--- a/lib/src/observable.dart
+++ b/lib/src/observable.dart
@@ -19,7 +19,7 @@
/// - Implement the interface yourself and provide your own implementation
abstract class Observable<C extends ChangeRecord> {
// To be removed when https://github.com/dart-lang/observable/issues/10
- final ChangeNotifier<C> _delegate = new ChangeNotifier<C>();
+ final ChangeNotifier<C> _delegate = ChangeNotifier<C>();
// Whether Observable was not given a type.
final bool _isNotGeneric = C == dynamic || C == ChangeRecord;
@@ -81,7 +81,7 @@
if (hasObservers && oldValue != newValue) {
if (_isNotGeneric) {
notifyChange(
- new PropertyChangeRecord(
+ PropertyChangeRecord(
this,
field,
oldValue,
diff --git a/lib/src/observable_list.dart b/lib/src/observable_list.dart
index b7bd916..a502771 100644
--- a/lib/src/observable_list.dart
+++ b/lib/src/observable_list.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// ignore_for_file: deprecated_member_use_from_same_package
library observable.src.observable_list;
import 'dart:async';
@@ -27,7 +28,7 @@
/// and if all elements stored into the returned list are actually instance
/// of [S], then the returned list can be used as a `ObservableList<T>`.
static ObservableList<T> castFrom<S, T>(ObservableList<S> source) =>
- new ObservableList<T>._spy(source._list.cast<T>());
+ ObservableList<T>._spy(source._list.cast<T>());
List<ListChangeRecord<E>> _listRecords;
@@ -44,7 +45,7 @@
/// If a [length] argument is supplied, a fixed size list of that
/// length is created.
ObservableList([int length])
- : _list = length != null ? new List<E>(length) : <E>[];
+ : _list = length != null ? List<E>(length) : <E>[];
/// Creates an observable list of the given [length].
///
@@ -56,7 +57,7 @@
/// Creates an observable list with the elements of [other]. The order in
/// the list will be the order provided by the iterator of [other].
- ObservableList.from(Iterable other) : _list = new List<E>.from(other);
+ ObservableList.from(Iterable other) : _list = List<E>.from(other);
ObservableList._spy(List<E> other) : _list = other;
@@ -111,7 +112,7 @@
Stream<List<ListChangeRecord<E>>> get listChanges {
if (_listChanges == null) {
// TODO(jmesserly): split observed/unobserved notions?
- _listChanges = new StreamController.broadcast(
+ _listChanges = StreamController.broadcast(
sync: true,
onCancel: () {
_listChanges = null;
@@ -234,7 +235,7 @@
@override
void insertAll(int index, Iterable<E> iterable) {
if (index < 0 || index > length) {
- throw new RangeError.range(index, 0, length);
+ throw RangeError.range(index, 0, length);
}
// TODO(floitsch): we can probably detect more cases.
if (iterable is! List && iterable is! Set) {
@@ -260,7 +261,7 @@
@override
void insert(int index, E element) {
if (index < 0 || index > length) {
- throw new RangeError.range(index, 0, length);
+ throw RangeError.range(index, 0, length);
}
if (index == length) {
add(element);
@@ -269,7 +270,7 @@
// We are modifying the length just below the is-check. Without the check
// Array.copy could throw an exception, leaving the list in a bad state
// (with a length that has been increased, but without a new element).
- if (index is! int) throw new ArgumentError(index);
+ if (index is! int) throw ArgumentError(index);
_list.length++;
_list.setRange(index + 1, length, this, index);
@@ -289,10 +290,10 @@
void _rangeCheck(int start, int end) {
if (start < 0 || start > this.length) {
- throw new RangeError.range(start, 0, this.length);
+ throw RangeError.range(start, 0, this.length);
}
if (end < start || end > this.length) {
- throw new RangeError.range(end, start, this.length);
+ throw RangeError.range(end, start, this.length);
}
}
@@ -306,7 +307,7 @@
_listRecords = [];
scheduleMicrotask(deliverListChanges);
}
- _listRecords.add(new ListChangeRecord<E>(
+ _listRecords.add(ListChangeRecord<E>(
this,
index,
removed: removed,
@@ -331,7 +332,7 @@
_listRecords = null;
if (hasListObservers && records.isNotEmpty) {
- _listChanges.add(new UnmodifiableListView<ListChangeRecord<E>>(records));
+ _listChanges.add(UnmodifiableListView<ListChangeRecord<E>>(records));
return true;
}
return false;
@@ -353,7 +354,7 @@
List<E> oldValue,
List<E> newValue,
) {
- return new ListDiffer<E>().diff(oldValue, newValue);
+ return ListDiffer<E>().diff(oldValue, newValue);
}
/// Updates the [previous] list using the [changeRecords]. For added items,
@@ -361,7 +362,7 @@
static void applyChangeRecords(List<Object> previous, List<Object> current,
List<ListChangeRecord> changeRecords) {
if (identical(previous, current)) {
- throw new ArgumentError("can't use same list for previous and current");
+ throw ArgumentError("can't use same list for previous and current");
}
for (ListChangeRecord change in changeRecords) {
diff --git a/lib/src/observable_map.dart b/lib/src/observable_map.dart
index bb1c844..7410a31 100644
--- a/lib/src/observable_map.dart
+++ b/lib/src/observable_map.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// ignore_for_file: deprecated_member_use_from_same_package
library observable.src.observable_map;
import 'dart:collection';
@@ -35,19 +36,19 @@
static ObservableMap<K2, V2> castFrom<K, V, K2, V2>(
ObservableMap<K, V> source,
) {
- return new ObservableMap<K2, V2>.spy(source._map.cast<K2, V2>());
+ return ObservableMap<K2, V2>.spy(source._map.cast<K2, V2>());
}
final Map<K, V> _map;
/// Creates an observable map.
- ObservableMap() : _map = new HashMap<K, V>();
+ ObservableMap() : _map = HashMap<K, V>();
/// Creates a new observable map using a [LinkedHashMap].
- ObservableMap.linked() : _map = new LinkedHashMap<K, V>();
+ ObservableMap.linked() : _map = LinkedHashMap<K, V>();
/// Creates a new observable map using a [SplayTreeMap].
- ObservableMap.sorted() : _map = new SplayTreeMap<K, V>();
+ ObservableMap.sorted() : _map = SplayTreeMap<K, V>();
/// Creates an observable map that contains all key value pairs of [other].
/// It will attempt to use the same backing map type if the other map is a
@@ -57,18 +58,18 @@
/// Note this will perform a shallow conversion. If you want a deep conversion
/// you should use [toObservable].
factory ObservableMap.from(Map<K, V> other) {
- return new ObservableMap<K, V>.createFromType(other)..addAll(other);
+ return ObservableMap<K, V>.createFromType(other)..addAll(other);
}
/// Like [ObservableMap.from], but creates an empty map.
factory ObservableMap.createFromType(Map<K, V> other) {
ObservableMap<K, V> result;
if (other is SplayTreeMap) {
- result = new ObservableMap<K, V>.sorted();
+ result = ObservableMap<K, V>.sorted();
} else if (other is LinkedHashMap) {
- result = new ObservableMap<K, V>.linked();
+ result = ObservableMap<K, V>.linked();
} else {
- result = new ObservableMap<K, V>();
+ result = ObservableMap<K, V>();
}
return result;
}
@@ -114,10 +115,10 @@
if (len != _map.length) {
notifyPropertyChange(#length, len, _map.length);
- notifyChange(new MapChangeRecord.insert(key, value));
+ notifyChange(MapChangeRecord.insert(key, value));
_notifyKeysValuesChanged();
} else if (oldValue != value) {
- notifyChange(new MapChangeRecord(key, oldValue, value));
+ notifyChange(MapChangeRecord(key, oldValue, value));
_notifyValuesChanged();
}
}
@@ -135,7 +136,7 @@
V result = _map.putIfAbsent(key, ifAbsent);
if (hasObservers && len != _map.length) {
notifyPropertyChange(#length, len, _map.length);
- notifyChange(new MapChangeRecord.insert(key, result));
+ notifyChange(MapChangeRecord.insert(key, result));
_notifyKeysValuesChanged();
}
return result;
@@ -146,7 +147,7 @@
int len = _map.length;
V result = _map.remove(key);
if (hasObservers && len != _map.length) {
- notifyChange(new MapChangeRecord.remove(key, result));
+ notifyChange(MapChangeRecord.remove(key, result));
notifyPropertyChange(#length, len, _map.length);
_notifyKeysValuesChanged();
}
@@ -158,7 +159,7 @@
int len = _map.length;
if (hasObservers && len > 0) {
_map.forEach((key, value) {
- notifyChange(new MapChangeRecord.remove(key, value));
+ notifyChange(MapChangeRecord.remove(key, value));
});
notifyPropertyChange(#length, len, 0);
_notifyKeysValuesChanged();
@@ -211,11 +212,11 @@
// Note: we don't really have a reasonable old/new value to use here.
// But this should fix "keys" and "values" in templates with minimal overhead.
void _notifyKeysValuesChanged() {
- notifyChange(new PropertyChangeRecord(this, #keys, null, null));
+ notifyChange(PropertyChangeRecord(this, #keys, null, null));
_notifyValuesChanged();
}
void _notifyValuesChanged() {
- notifyChange(new PropertyChangeRecord(this, #values, null, null));
+ notifyChange(PropertyChangeRecord(this, #values, null, null));
}
}
diff --git a/lib/src/records/list_change_record.dart b/lib/src/records/list_change_record.dart
index beb7645..7f18716 100644
--- a/lib/src/records/list_change_record.dart
+++ b/lib/src/records/list_change_record.dart
@@ -30,13 +30,13 @@
List<E> removed,
int addedCount = 0,
}) {
- return new ListChangeRecord._(
- object, index, removed ?? new UnmodifiableListView([]), addedCount);
+ return ListChangeRecord._(
+ object, index, removed ?? UnmodifiableListView([]), addedCount);
}
/// Records an `add` operation at `object[index]` of [addedCount] elements.
ListChangeRecord.add(this.object, this.index, this.addedCount)
- : removed = new UnmodifiableListView([]) {
+ : removed = UnmodifiableListView([]) {
_assertValidState();
}
@@ -83,16 +83,16 @@
void _assertValidState() {
assert(() {
if (object == null) {
- throw new ArgumentError.notNull('object');
+ throw ArgumentError.notNull('object');
}
if (index == null) {
- throw new ArgumentError.notNull('index');
+ throw ArgumentError.notNull('index');
}
if (removed == null) {
- throw new ArgumentError.notNull('removed');
+ throw ArgumentError.notNull('removed');
}
if (addedCount == null || addedCount < 0) {
- throw new ArgumentError('Invalid `addedCount`: $addedCount');
+ throw ArgumentError('Invalid `addedCount`: $addedCount');
}
return true;
}());
diff --git a/lib/src/to_observable.dart b/lib/src/to_observable.dart
index 20f8d7e..98432c2 100644
--- a/lib/src/to_observable.dart
+++ b/lib/src/to_observable.dart
@@ -41,7 +41,7 @@
/// for a shallow conversion. This does not handle circular data structures.
/// If a conversion is peformed, mutations are only observed to the result of
/// this function. Changing the original collection will not affect it.
-ObservableList<T> toObservableList<T>(Iterable<T> value, {bool deep: true}) {
+ObservableList<T> toObservableList<T>(Iterable<T> value, {bool deep = true}) {
if (value is Observable) return value;
return deep ? _toObservableDeepIterable(value) : _toObservableShallow(value);
}
@@ -57,7 +57,7 @@
/// for a shallow conversion. This does not handle circular data structures.
/// If a conversion is peformed, mutations are only observed to the result of
/// this function. Changing the original collection will not affect it.
-ObservableMap<K, V> toObservableMap<K, V>(Map<K, V> value, {bool deep: true}) {
+ObservableMap<K, V> toObservableMap<K, V>(Map<K, V> value, {bool deep = true}) {
if (value is Observable) return value;
return deep ? _toObservableDeepMap(value) : _toObservableShallow(value);
}
@@ -67,12 +67,12 @@
if (value is Map) {
return extractMapTypeArguments(
- value, <K, V>() => new ObservableMap<K, V>.from(value));
+ value, <K, V>() => ObservableMap<K, V>.from(value));
}
if (value is Iterable) {
return extractIterableTypeArgument(
- value, <T>() => new ObservableList<T>.from(value));
+ value, <T>() => ObservableList<T>.from(value));
}
return value;
@@ -90,7 +90,7 @@
ObservableMap _toObservableDeepMap(Map<dynamic, dynamic> value) {
return extractMapTypeArguments(value, <K, V>() {
- var result = new ObservableMap<K, V>.createFromType(value);
+ var result = ObservableMap<K, V>.createFromType(value);
value.forEach((k, v) {
result[_toObservableDeep(k)] = _toObservableDeep(v);
});
@@ -100,7 +100,7 @@
ObservableList _toObservableDeepIterable(Iterable<dynamic> value) {
return extractIterableTypeArgument(value, <T>() {
- var result = new ObservableList<T>();
+ var result = ObservableList<T>();
for (var element in value) {
result.add(_toObservableDeep(element));
}
diff --git a/test/list_change_test.dart b/test/list_change_test.dart
index 4d47a72..fe53ccc 100644
--- a/test/list_change_test.dart
+++ b/test/list_change_test.dart
@@ -39,7 +39,7 @@
model.add(2);
expect(summary, null);
- return new Future(() {
+ return Future(() {
expect(summary, [_delta(1, [], 2, typedModel: model)]);
expect(summary[0].added, [1, 2]);
expect(summary[0].removed, []);
@@ -53,7 +53,7 @@
sub = model.listChanges.listen((r) => summary = r);
model.length = 2;
- return new Future(() {
+ return Future(() {
expect(summary, [
_delta(2, ['c', 'd', 'e'], 0, typedModel: model)
]);
diff --git a/test/map_differ_test.dart b/test/map_differ_test.dart
index 7fb9ca9..40268e4 100644
--- a/test/map_differ_test.dart
+++ b/test/map_differ_test.dart
@@ -6,18 +6,18 @@
final diff = const MapDiffer<String, String>().diff;
test('should emit no changes for identical maps', () {
- final map = new Map<String, String>.fromIterable(
- new Iterable.generate(10, (i) => '$i'),
+ final map = Map<String, String>.fromIterable(
+ Iterable.generate(10, (i) => '$i'),
);
expect(diff(map, map), isEmpty);
});
test('should emit no changes for maps with identical content', () {
- final map1 = new Map<String, String>.fromIterable(
- new Iterable.generate(10, (i) => '$i'),
+ final map1 = Map<String, String>.fromIterable(
+ Iterable.generate(10, (i) => '$i'),
);
- final map2 = new Map<String, String>.fromIterable(
- new Iterable.generate(10, (i) => '$i'),
+ final map2 = Map<String, String>.fromIterable(
+ Iterable.generate(10, (i) => '$i'),
);
expect(diff(map1, map2), isEmpty);
});
@@ -33,7 +33,7 @@
'key-c': 'value-c',
}),
[
- new MapChangeRecord.insert('key-c', 'value-c'),
+ MapChangeRecord.insert('key-c', 'value-c'),
],
);
});
@@ -49,7 +49,7 @@
'key-b': 'value-b',
}),
[
- new MapChangeRecord.remove('key-c', 'value-c'),
+ MapChangeRecord.remove('key-c', 'value-c'),
],
);
});
@@ -64,7 +64,7 @@
'key-b': 'value-b-new',
}),
[
- new MapChangeRecord('key-b', 'value-b-old', 'value-b-new'),
+ MapChangeRecord('key-b', 'value-b-old', 'value-b-new'),
],
);
});
@@ -81,7 +81,7 @@
'key-b': 'value-b',
'key-c': 'value-c',
};
- new MapChangeRecord.insert('key-c', 'value-c').apply(map1);
+ MapChangeRecord.insert('key-c', 'value-c').apply(map1);
expect(map1, map2);
});
@@ -95,7 +95,7 @@
'key-a': 'value-a',
'key-b': 'value-b',
};
- new MapChangeRecord.remove('key-c', 'value-c').apply(map1);
+ MapChangeRecord.remove('key-c', 'value-c').apply(map1);
expect(map1, map2);
});
@@ -108,7 +108,7 @@
'key-a': 'value-a',
'key-b': 'value-b-new',
};
- new MapChangeRecord('key-b', 'value-b-old', 'value-b-new').apply(map1);
+ MapChangeRecord('key-b', 'value-b-old', 'value-b-new').apply(map1);
expect(map1, map2);
});
});
diff --git a/test/observable_list_test.dart b/test/observable_list_test.dart
index fee070d..73573c4 100644
--- a/test/observable_list_test.dart
+++ b/test/observable_list_test.dart
@@ -42,7 +42,7 @@
test('add changes length', () {
list.add(4);
expect(list, [1, 2, 3, 4]);
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(3, 4)]));
});
});
@@ -51,7 +51,7 @@
list.remove(2);
expect(list, orderedEquals([1, 3]));
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(3, 2)]));
});
});
@@ -60,7 +60,7 @@
list.add(4);
list.removeRange(1, 3);
expect(list, [1, 4]);
- return new Future(() {
+ return Future(() {
expect(changes,
changeMatchers([_lengthChange(3, 4), _lengthChange(4, 2)]));
});
@@ -70,7 +70,7 @@
list.add(2);
list.removeWhere((e) => e == 2);
expect(list, [1, 3]);
- return new Future(() {
+ return Future(() {
expect(changes,
changeMatchers([_lengthChange(3, 4), _lengthChange(4, 2)]));
});
@@ -79,7 +79,7 @@
test('length= changes length', () {
list.length = 5;
expect(list, [1, 2, 3, null, null]);
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(3, 5)]));
});
});
@@ -87,7 +87,7 @@
test('[]= does not change length', () {
list[2] = 9000;
expect(list, [1, 2, 9000]);
- return new Future(() {
+ return Future(() {
expect(changes, null);
});
});
@@ -95,7 +95,7 @@
test('clear changes length', () {
list.clear();
expect(list, []);
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(3, 0)]));
});
});
@@ -117,7 +117,7 @@
test('add does not change existing items', () {
list.add(4);
expect(list, [1, 2, 3, 4]);
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -125,7 +125,7 @@
test('[]= changes item', () {
list[1] = 777;
expect(list, [1, 777, 3]);
- return new Future(() {
+ return Future(() {
expect(changes, [
_change(1, addedCount: 1, removed: [2])
]);
@@ -135,7 +135,7 @@
test('[]= on a different item does not fire change', () {
list[2] = 9000;
expect(list, [1, 2, 9000]);
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -144,7 +144,7 @@
list[1] = 777;
list[1] = 42;
expect(list, [1, 42, 3]);
- return new Future(() {
+ return Future(() {
expect(changes, [
_change(1, addedCount: 1, removed: [2]),
]);
@@ -154,7 +154,7 @@
test('set length without truncating item means no change', () {
list.length = 2;
expect(list, [1, 2]);
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -162,7 +162,7 @@
test('truncate removes item', () {
list.length = 1;
expect(list, [1]);
- return new Future(() {
+ return Future(() {
expect(changes, [
_change(1, removed: [2, 3])
]);
@@ -173,7 +173,7 @@
list.length = 1;
list.add(42);
expect(list, [1, 42]);
- return new Future(() {
+ return Future(() {
expect(changes, [
_change(1, removed: [2, 3], addedCount: 1)
]);
@@ -184,7 +184,7 @@
list.length = 1;
list.add(2);
expect(list, [1, 2]);
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -217,10 +217,10 @@
expect(list.indexOf(1, 1), 3);
expect(list.lastIndexOf(1), 3);
expect(list.last, 4);
- var copy = new List<int>();
+ var copy = List<int>();
list.forEach((int i) => copy.add(i));
expect(copy, orderedEquals([1, 2, 3, 1, 3, 4]));
- return new Future(() {
+ return Future(() {
// no change from read-only operators
expect(propRecords, null);
expect(listRecords, null);
@@ -232,7 +232,7 @@
list.add(6);
expect(list, orderedEquals([1, 2, 3, 1, 3, 4, 5, 6]));
- return new Future(() {
+ return Future(() {
expect(
propRecords,
changeMatchers([
@@ -247,7 +247,7 @@
list[1] = list.last;
expect(list, orderedEquals([1, 4, 3, 1, 3, 4]));
- return new Future(() {
+ return Future(() {
expect(propRecords, null);
expect(listRecords, [
_change(1, addedCount: 1, removed: [2])
@@ -259,7 +259,7 @@
expect(list.removeLast(), 4);
expect(list, orderedEquals([1, 2, 3, 1, 3]));
- return new Future(() {
+ return Future(() {
expect(propRecords, changeMatchers([_lengthChange(6, 5)]));
expect(listRecords, [
_change(5, removed: [4])
@@ -271,7 +271,7 @@
list.removeRange(1, 4);
expect(list, orderedEquals([1, 3, 4]));
- return new Future(() {
+ return Future(() {
expect(propRecords, changeMatchers([_lengthChange(6, 3)]));
expect(listRecords, [
_change(1, removed: [2, 3, 1])
@@ -283,7 +283,7 @@
list.removeWhere((e) => e == 3);
expect(list, orderedEquals([1, 2, 1, 4]));
- return new Future(() {
+ return Future(() {
expect(propRecords, changeMatchers([_lengthChange(6, 4)]));
expect(listRecords, [
_change(2, removed: [3]),
@@ -296,7 +296,7 @@
list.sort((x, y) => x - y);
expect(list, orderedEquals([1, 1, 2, 3, 3, 4]));
- return new Future(() {
+ return Future(() {
expect(propRecords, null);
expect(listRecords, [
_change(1, addedCount: 1),
@@ -323,7 +323,7 @@
list.clear();
expect(list, []);
- return new Future(() {
+ return Future(() {
expect(
propRecords,
changeMatchers([
@@ -342,7 +342,7 @@
ObservableList<int> list;
PropertyChangeRecord<int> _lengthChange(int oldValue, int newValue) =>
- new PropertyChangeRecord<int>(list, #length, oldValue, newValue);
+ PropertyChangeRecord<int>(list, #length, oldValue, newValue);
_change(int index, {List removed = const [], int addedCount = 0}) =>
- new ListChangeRecord(list, index, removed: removed, addedCount: addedCount);
+ ListChangeRecord(list, index, removed: removed, addedCount: addedCount);
diff --git a/test/observable_map_test.dart b/test/observable_map_test.dart
index 1bc0062..569132e 100644
--- a/test/observable_map_test.dart
+++ b/test/observable_map_test.dart
@@ -40,7 +40,7 @@
test('add item changes length', () {
map['d'] = 4;
expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(map, 3, 4)]));
});
});
@@ -48,7 +48,7 @@
test('putIfAbsent changes length', () {
map.putIfAbsent('d', () => 4);
expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(map, 3, 4)]));
});
});
@@ -57,7 +57,7 @@
map.remove('c');
map.remove('a');
expect(map, {'b': 2});
- return new Future(() {
+ return Future(() {
expect(
changes,
changeMatchers([
@@ -70,7 +70,7 @@
test('remove non-existent item does not change length', () {
map.remove('d');
expect(map, {'a': 1, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, null);
});
});
@@ -78,7 +78,7 @@
test('set existing item does not change length', () {
map['c'] = 9000;
expect(map, {'a': 1, 'b': 2, 'c': 9000});
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -86,7 +86,7 @@
test('clear changes length', () {
map.clear();
expect(map, {});
- return new Future(() {
+ return Future(() {
expect(changes, changeMatchers([_lengthChange(map, 3, 0)]));
});
});
@@ -110,7 +110,7 @@
test('putIfAbsent new item does not change existing item', () {
map.putIfAbsent('d', () => 4);
expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -118,7 +118,7 @@
test('set item to null', () {
map['b'] = null;
expect(map, {'a': 1, 'b': null, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, [_changeKey('b', 2, null)]);
});
});
@@ -126,7 +126,7 @@
test('set item to value', () {
map['b'] = 777;
expect(map, {'a': 1, 'b': 777, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, [_changeKey('b', 2, 777)]);
});
});
@@ -134,7 +134,7 @@
test('putIfAbsent does not change if already there', () {
map.putIfAbsent('b', () => 1234);
expect(map, {'a': 1, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, null);
});
});
@@ -142,7 +142,7 @@
test('change a different item', () {
map['c'] = 9000;
expect(map, {'a': 1, 'b': 2, 'c': 9000});
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -151,7 +151,7 @@
map['b'] = 9001;
map['b'] = 42;
expect(map, {'a': 1, 'b': 42, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, [
_changeKey('b', 2, 9001),
_changeKey('b', 9001, 42),
@@ -162,7 +162,7 @@
test('remove other items', () {
map.remove('a');
expect(map, {'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, []);
});
});
@@ -170,7 +170,7 @@
test('remove the item', () {
map.remove('b');
expect(map, {'a': 1, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, [_removeKey('b', 2)]);
});
});
@@ -179,7 +179,7 @@
map.remove('b');
map['b'] = 2;
expect(map, {'a': 1, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(changes, [
_removeKey('b', 2),
_insertKey('b', 2),
@@ -213,7 +213,7 @@
test('add item changes keys/values', () {
map['d'] = 4;
expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 1);
expect(valuesChanged, 1);
});
@@ -222,7 +222,7 @@
test('putIfAbsent changes keys/values', () {
map.putIfAbsent('d', () => 4);
expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 1);
expect(valuesChanged, 1);
});
@@ -232,7 +232,7 @@
map.remove('c');
map.remove('a');
expect(map, {'b': 2});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 2);
expect(valuesChanged, 2);
});
@@ -241,7 +241,7 @@
test('remove non-existent item does not change keys/values', () {
map.remove('d');
expect(map, {'a': 1, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 0);
expect(valuesChanged, 0);
});
@@ -250,7 +250,7 @@
test('set existing item does not change keys', () {
map['c'] = 9000;
expect(map, {'a': 1, 'b': 2, 'c': 9000});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 0);
expect(valuesChanged, 1);
});
@@ -259,7 +259,7 @@
test('clear changes keys/values', () {
map.clear();
expect(map, {});
- return new Future(() {
+ return Future(() {
expect(keysChanged, 1);
expect(valuesChanged, 1);
});
@@ -290,7 +290,7 @@
var copy = {};
map.forEach((k, v) => copy[k] = v);
expect(copy, {'a': 1, 'b': 2});
- return new Future(() {
+ return Future(() {
// no change from read-only operators
expect(records, null);
@@ -306,7 +306,7 @@
map.putIfAbsent('c', () => 3);
expect(map, {'a': 1, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(
records,
changeMatchers([
@@ -325,7 +325,7 @@
map['c'] = 3;
expect(map, {'a': 42, 'b': 2, 'c': 3});
- return new Future(() {
+ return Future(() {
expect(
records,
changeMatchers([
@@ -343,7 +343,7 @@
map.remove('b');
expect(map, {'a': 1});
- return new Future(() {
+ return Future(() {
expect(
records,
changeMatchers([
@@ -359,7 +359,7 @@
map.clear();
expect(map, {});
- return new Future(() {
+ return Future(() {
expect(
records,
changeMatchers([
@@ -379,7 +379,7 @@
setUp(() {
delegate = {};
- map = new ObservableMap.spy(delegate);
+ map = ObservableMap.spy(delegate);
});
test('[]=', () {
@@ -395,9 +395,9 @@
MapChangeRecord _changeKey(key, old, newValue) =>
MapChangeRecord(key, old, newValue);
-_insertKey(key, newValue) => new MapChangeRecord.insert(key, newValue);
+_insertKey(key, newValue) => MapChangeRecord.insert(key, newValue);
-_removeKey(key, oldValue) => new MapChangeRecord.remove(key, oldValue);
+_removeKey(key, oldValue) => MapChangeRecord.remove(key, oldValue);
PropertyChangeRecord<Null> _propChange(map, prop) =>
- new PropertyChangeRecord<Null>(map, prop, null, null);
+ PropertyChangeRecord<Null>(map, prop, null, null);
diff --git a/test/observable_test.dart b/test/observable_test.dart
index 094c718..e74660c 100644
--- a/test/observable_test.dart
+++ b/test/observable_test.dart
@@ -20,12 +20,14 @@
});
tearDown(() {
- for (var sub in subs) sub.cancel();
+ for (var sub in subs) {
+ sub.cancel();
+ }
});
test('handle future result', () {
- var callback = expectAsync(() {});
- return new Future(callback);
+ var callback = expectAsync0(() {});
+ return Future(callback);
});
test('no observers', () {
@@ -48,7 +50,7 @@
var t = createModel(123);
int called = 0;
- subs.add(t.changes.listen(expectAsync((records) {
+ subs.add(t.changes.listen(expectAsync1((records) {
called++;
expectPropertyChanges(records, 2);
})));
@@ -62,7 +64,7 @@
var t = createModel(123);
int called = 0;
- subs.add(t.changes.listen(expectAsync((records) {
+ subs.add(t.changes.listen(expectAsync1((records) {
called++;
expectPropertyChanges(records, 1);
if (called == 1) {
@@ -81,8 +83,8 @@
expectPropertyChanges(records, 2);
}
- subs.add(t.changes.listen(expectAsync(verifyRecords)));
- subs.add(t.changes.listen(expectAsync(verifyRecords)));
+ subs.add(t.changes.listen(expectAsync1(verifyRecords)));
+ subs.add(t.changes.listen(expectAsync1(verifyRecords)));
t.value = 41;
t.value = 42;
@@ -98,7 +100,7 @@
t.value = 42;
expect(records, [], reason: 'changes delived async');
- return new Future(() {
+ return Future(() {
expectPropertyChanges(records, 2);
records.clear();
@@ -112,7 +114,7 @@
test('cancel listening', () {
var t = createModel(123);
var sub;
- sub = t.changes.listen(expectAsync((records) {
+ sub = t.changes.listen(expectAsync1((records) {
expectPropertyChanges(records, 1);
sub.cancel();
t.value = 777;
@@ -123,12 +125,12 @@
test('cancel and reobserve', () {
var t = createModel(123);
var sub;
- sub = t.changes.listen(expectAsync((records) {
+ sub = t.changes.listen(expectAsync1((records) {
expectPropertyChanges(records, 1);
sub.cancel();
scheduleMicrotask(() {
- subs.add(t.changes.listen(expectAsync((records) {
+ subs.add(t.changes.listen(expectAsync1((records) {
expectPropertyChanges(records, 1);
})));
t.value = 777;
@@ -145,13 +147,13 @@
}));
t.value = 42;
- return new Future(() {
+ return Future(() {
expectPropertyChanges(records, 1);
// Verify that mutation operations on the list fail:
expect(() {
- records[0] = new PropertyChangeRecord(t, #value, 0, 1);
+ records[0] = PropertyChangeRecord(t, #value, 0, 1);
}, throwsUnsupportedError);
expect(() {
@@ -170,9 +172,9 @@
subs.add(t.changes.listen((r) {
records.addAll(r);
}));
- t.notifyChange(new PropertyChangeRecord(t, #value, 123, 42));
+ t.notifyChange(PropertyChangeRecord(t, #value, 123, 42));
- return new Future(() {
+ return Future(() {
expectPropertyChanges(records, 1);
expect(t.value, 123, reason: 'value did not actually change.');
});
@@ -187,7 +189,7 @@
expect(t.notifyPropertyChange(#value, t.value, 42), 42,
reason: 'notifyPropertyChange returns newValue');
- return new Future(() {
+ return Future(() {
expectPropertyChanges(records, 1);
expect(t.value, 123, reason: 'value did not actually change.');
});
@@ -204,7 +206,7 @@
}
}
-createModel(int number) => new ObservableSubclass(number);
+createModel(int number) => ObservableSubclass(number);
class ObservableSubclass<T> extends PropertyChangeNotifier {
ObservableSubclass([T initialValue]) : _value = initialValue;
diff --git a/test/observable_test_utils.dart b/test/observable_test_utils.dart
index bbb5b70..b705e7c 100644
--- a/test/observable_test_utils.dart
+++ b/test/observable_test_utils.dart
@@ -13,7 +13,7 @@
/// to happen in the next microtask:
///
/// future.then(newMicrotask).then(...)
-newMicrotask(_) => new Future.value();
+newMicrotask(_) => Future.value();
void expectChanges(List<ChangeRecord> actual, List<ChangeRecord> expected,
{String reason}) {
@@ -27,11 +27,11 @@
List<ListChangeRecord> getListChangeRecords(
List<ListChangeRecord> changes, int index) =>
- new List.from(changes.where((ListChangeRecord c) => c.indexChanged(index)));
+ List.from(changes.where((ListChangeRecord c) => c.indexChanged(index)));
List<PropertyChangeRecord> getPropertyChangeRecords(
List<ChangeRecord> changes, Symbol property) =>
- new List.from(changes.where(
+ List.from(changes.where(
(ChangeRecord c) => c is PropertyChangeRecord && c.name == property));
List<Matcher> changeMatchers(List<ChangeRecord> changes) => changes