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

Unified Diff: pkg/observe/test/observable_list_test.dart

Issue 132403010: big update to observe, template_binding, polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/observe/test/list_change_test.dart ('k') | pkg/observe/test/observable_map_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/test/observable_list_test.dart
diff --git a/pkg/observe/test/observable_list_test.dart b/pkg/observe/test/observable_list_test.dart
index 66a03d343df7110e85cc31d79faa74d25b074ca0..81ca45f431de01c586f6c0f6611ff0ff8a9ab0ae 100644
--- a/pkg/observe/test/observable_list_test.dart
+++ b/pkg/observe/test/observable_list_test.dart
@@ -7,7 +7,9 @@ import 'package:observe/observe.dart';
import 'package:unittest/unittest.dart';
import 'observe_test_utils.dart';
-main() {
+main() => dirtyCheckZone().run(_runTests);
+
+_runTests() {
// TODO(jmesserly): need all standard List API tests.
StreamSubscription sub, sub2;
@@ -36,48 +38,54 @@ main() {
tearDown(sharedTearDown);
- observeTest('add changes length', () {
+ test('add changes length', () {
list.add(4);
expect(list, [1, 2, 3, 4]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_lengthChange(3, 4)]);
+ return new Future(() {
+ expectChanges(changes, [_lengthChange(3, 4)]);
+ });
});
- observeTest('removeObject', () {
+ test('removeObject', () {
list.remove(2);
expect(list, orderedEquals([1, 3]));
- performMicrotaskCheckpoint();
- expectChanges(changes, [_lengthChange(3, 2)]);
+ return new Future(() {
+ expectChanges(changes, [_lengthChange(3, 2)]);
+ });
});
- observeTest('removeRange changes length', () {
+ test('removeRange changes length', () {
list.add(4);
list.removeRange(1, 3);
expect(list, [1, 4]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_lengthChange(3, 4), _lengthChange(4, 2)]);
+ return new Future(() {
+ expectChanges(changes, [_lengthChange(3, 4), _lengthChange(4, 2)]);
+ });
});
- observeTest('length= changes length', () {
+ test('length= changes length', () {
list.length = 5;
expect(list, [1, 2, 3, null, null]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_lengthChange(3, 5)]);
+ return new Future(() {
+ expectChanges(changes, [_lengthChange(3, 5)]);
+ });
});
- observeTest('[]= does not change length', () {
+ test('[]= does not change length', () {
list[2] = 9000;
expect(list, [1, 2, 9000]);
- performMicrotaskCheckpoint();
- expectChanges(changes, null);
+ return new Future(() {
+ expectChanges(changes, null);
+ });
});
- observeTest('clear changes length', () {
+ test('clear changes length', () {
list.clear();
expect(list, []);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_lengthChange(3, 0)]);
+ return new Future(() {
+ expectChanges(changes, [_lengthChange(3, 0)]);
+ });
});
});
@@ -94,71 +102,79 @@ main() {
tearDown(sharedTearDown);
- observeTest('add does not change existing items', () {
+ test('add does not change existing items', () {
list.add(4);
expect(list, [1, 2, 3, 4]);
- performMicrotaskCheckpoint();
- expectChanges(changes, []);
+ return new Future(() {
+ expectChanges(changes, []);
+ });
});
- observeTest('[]= changes item', () {
+ test('[]= changes item', () {
list[1] = 777;
expect(list, [1, 777, 3]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_change(1, addedCount: 1, removed: [2])]);
+ return new Future(() {
+ expectChanges(changes, [_change(1, addedCount: 1, removed: [2])]);
+ });
});
- observeTest('[]= on a different item does not fire change', () {
+ test('[]= on a different item does not fire change', () {
list[2] = 9000;
expect(list, [1, 2, 9000]);
- performMicrotaskCheckpoint();
- expectChanges(changes, []);
+ return new Future(() {
+ expectChanges(changes, []);
+ });
});
- observeTest('set multiple times results in one change', () {
+ test('set multiple times results in one change', () {
list[1] = 777;
list[1] = 42;
expect(list, [1, 42, 3]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [
- _change(1, addedCount: 1, removed: [2]),
- ]);
+ return new Future(() {
+ expectChanges(changes, [
+ _change(1, addedCount: 1, removed: [2]),
+ ]);
+ });
});
- observeTest('set length without truncating item means no change', () {
+ test('set length without truncating item means no change', () {
list.length = 2;
expect(list, [1, 2]);
- performMicrotaskCheckpoint();
- expectChanges(changes, []);
+ return new Future(() {
+ expectChanges(changes, []);
+ });
});
- observeTest('truncate removes item', () {
+ test('truncate removes item', () {
list.length = 1;
expect(list, [1]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [_change(1, removed: [2, 3])]);
+ return new Future(() {
+ expectChanges(changes, [_change(1, removed: [2, 3])]);
+ });
});
- observeTest('truncate and add new item', () {
+ test('truncate and add new item', () {
list.length = 1;
list.add(42);
expect(list, [1, 42]);
- performMicrotaskCheckpoint();
- expectChanges(changes, [
- _change(1, removed: [2, 3], addedCount: 1)
- ]);
+ return new Future(() {
+ expectChanges(changes, [
+ _change(1, removed: [2, 3], addedCount: 1)
+ ]);
+ });
});
- observeTest('truncate and add same item', () {
+ test('truncate and add same item', () {
list.length = 1;
list.add(2);
expect(list, [1, 2]);
- performMicrotaskCheckpoint();
- expectChanges(changes, []);
+ return new Future(() {
+ expectChanges(changes, []);
+ });
});
});
- observeTest('toString', () {
+ test('toString', () {
var list = toObservable([1, 2, 3]);
expect(list.toString(), '[1, 2, 3]');
});
@@ -178,7 +194,7 @@ main() {
tearDown(sharedTearDown);
- observeTest('read operations', () {
+ test('read operations', () {
expect(list.length, 6);
expect(list[0], 1);
expect(list.indexOf(4), 5);
@@ -189,76 +205,82 @@ main() {
var copy = new List<int>();
list.forEach((i) { copy.add(i); });
expect(copy, orderedEquals([1, 2, 3, 1, 3, 4]));
- performMicrotaskCheckpoint();
-
- // no change from read-only operators
- expectChanges(propRecords, null);
- expectChanges(listRecords, null);
+ return new Future(() {
+ // no change from read-only operators
+ expectChanges(propRecords, null);
+ expectChanges(listRecords, null);
+ });
});
- observeTest('add', () {
+ test('add', () {
list.add(5);
list.add(6);
expect(list, orderedEquals([1, 2, 3, 1, 3, 4, 5, 6]));
- performMicrotaskCheckpoint();
- expectChanges(propRecords, [
- _lengthChange(6, 7),
- _lengthChange(7, 8),
- ]);
- expectChanges(listRecords, [ _change(6, addedCount: 2) ]);
+ return new Future(() {
+ expectChanges(propRecords, [
+ _lengthChange(6, 7),
+ _lengthChange(7, 8),
+ ]);
+ expectChanges(listRecords, [ _change(6, addedCount: 2) ]);
+ });
});
- observeTest('[]=', () {
+ test('[]=', () {
list[1] = list.last;
expect(list, orderedEquals([1, 4, 3, 1, 3, 4]));
- performMicrotaskCheckpoint();
- expectChanges(propRecords, null);
- expectChanges(listRecords, [ _change(1, addedCount: 1, removed: [2]) ]);
+ return new Future(() {
+ expectChanges(propRecords, null);
+ expectChanges(listRecords, [ _change(1, addedCount: 1, removed: [2]) ]);
+ });
});
- observeTest('removeLast', () {
+ test('removeLast', () {
expect(list.removeLast(), 4);
expect(list, orderedEquals([1, 2, 3, 1, 3]));
- performMicrotaskCheckpoint();
- expectChanges(propRecords, [_lengthChange(6, 5)]);
- expectChanges(listRecords, [_change(5, removed: [4])]);
+ return new Future(() {
+ expectChanges(propRecords, [_lengthChange(6, 5)]);
+ expectChanges(listRecords, [_change(5, removed: [4])]);
+ });
});
- observeTest('removeRange', () {
+ test('removeRange', () {
list.removeRange(1, 4);
expect(list, orderedEquals([1, 3, 4]));
- performMicrotaskCheckpoint();
- expectChanges(propRecords, [_lengthChange(6, 3)]);
- expectChanges(listRecords, [_change(1, removed: [2, 3, 1])]);
+ return new Future(() {
+ expectChanges(propRecords, [_lengthChange(6, 3)]);
+ expectChanges(listRecords, [_change(1, removed: [2, 3, 1])]);
+ });
});
- observeTest('sort', () {
+ test('sort', () {
list.sort((x, y) => x - y);
expect(list, orderedEquals([1, 1, 2, 3, 3, 4]));
- performMicrotaskCheckpoint();
- expectChanges(propRecords, null);
- expectChanges(listRecords, [
- _change(1, addedCount: 1),
- _change(4, removed: [1])
- ]);
+ return new Future(() {
+ expectChanges(propRecords, null);
+ expectChanges(listRecords, [
+ _change(1, addedCount: 1),
+ _change(4, removed: [1])
+ ]);
+ });
});
- observeTest('clear', () {
+ test('clear', () {
list.clear();
expect(list, []);
- performMicrotaskCheckpoint();
- expectChanges(propRecords, [
- _lengthChange(6, 0),
- new PropertyChangeRecord(list, #isEmpty, false, true),
- new PropertyChangeRecord(list, #isNotEmpty, true, false),
- ]);
- expectChanges(listRecords, [_change(0, removed: [1, 2, 3, 1, 3, 4])]);
+ return new Future(() {
+ expectChanges(propRecords, [
+ _lengthChange(6, 0),
+ new PropertyChangeRecord(list, #isEmpty, false, true),
+ new PropertyChangeRecord(list, #isNotEmpty, true, false),
+ ]);
+ expectChanges(listRecords, [_change(0, removed: [1, 2, 3, 1, 3, 4])]);
+ });
});
});
}
« no previous file with comments | « pkg/observe/test/list_change_test.dart ('k') | pkg/observe/test/observable_map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698