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

Unified Diff: packages/observable/test/list_change_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/observable/pubspec.yaml ('k') | packages/observable/test/observable_list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/observable/test/list_change_test.dart
diff --git a/packages/observe/test/list_change_test.dart b/packages/observable/test/list_change_test.dart
similarity index 85%
rename from packages/observe/test/list_change_test.dart
rename to packages/observable/test/list_change_test.dart
index 30afb6073a42f3a0bc2ffae5c54fa59ad7c91cc0..b07c0b8cc8bcb767d512a6aec3e59b601d516fa7 100644
--- a/packages/observe/test/list_change_test.dart
+++ b/packages/observable/test/list_change_test.dart
@@ -1,16 +1,18 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// 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.
import 'dart:async';
-import 'package:observe/observe.dart';
-import 'package:unittest/unittest.dart';
-import 'observe_test_utils.dart';
+
+import 'package:observable/observable.dart';
+import 'package:test/test.dart';
+
+import 'observable_test_utils.dart';
// This file contains code ported from:
// https://github.com/rafaelw/ChangeSummary/blob/master/tests/test.js
-main() => dirtyCheckZone().run(listChangeTests);
+main() => listChangeTests();
// TODO(jmesserly): port or write array fuzzer tests
listChangeTests() {
@@ -29,7 +31,7 @@ listChangeTests() {
model.add(0);
var summary;
- sub = model.listChanges.listen((r) { summary = r; });
+ sub = model.listChanges.listen((r) => summary = r);
model.add(1);
model.add(2);
@@ -42,35 +44,34 @@ listChangeTests() {
model = toObservable(['a', 'b', 'c', 'd', 'e']);
var summary;
- sub = model.listChanges.listen((r) { summary = r; });
+ sub = model.listChanges.listen((r) => summary = r);
model.length = 2;
return new Future(() {
- expectChanges(summary, [_delta(2, ['c', 'd', 'e'], 0)]);
+ expectChanges(summary, [
+ _delta(2, ['c', 'd', 'e'], 0)
+ ]);
summary = null;
model.length = 5;
-
}).then(newMicrotask).then((_) {
-
expectChanges(summary, [_delta(2, [], 3)]);
});
});
group('List deltas can be applied', () {
-
applyAndCheckDeltas(model, copy, changes) => changes.then((summary) {
- // apply deltas to the copy
- for (var delta in summary) {
- copy.removeRange(delta.index, delta.index + delta.removed.length);
- for (int i = delta.addedCount - 1; i >= 0; i--) {
- copy.insert(delta.index, model[delta.index + i]);
- }
- }
-
- // Note: compare strings for easier debugging.
- expect('$copy', '$model', reason: 'summary $summary');
- });
+ // apply deltas to the copy
+ for (var delta in summary) {
+ copy.removeRange(delta.index, delta.index + delta.removed.length);
+ for (int i = delta.addedCount - 1; i >= 0; i--) {
+ copy.insert(delta.index, model[delta.index + i]);
+ }
+ }
+
+ // Note: compare strings for easier debugging.
+ expect('$copy', '$model', reason: 'summary $summary');
+ });
test('Contained', () {
var model = toObservable(['a', 'b']);
@@ -204,7 +205,7 @@ listChangeTests() {
var changes = model.listChanges.first;
model.removeAt(2);
- model.insertAll(2, ['e', 'f', 'g']); // a b [e f g] d
+ model.insertAll(2, ['e', 'f', 'g']); // a b [e f g] d
model[0] = 'h';
model.removeAt(1);
@@ -223,15 +224,14 @@ listChangeTests() {
});
group('edit distance', () {
-
assertEditDistance(orig, changes, expectedDist) => changes.then((summary) {
- var actualDistance = 0;
- for (var delta in summary) {
- actualDistance += delta.addedCount + delta.removed.length;
- }
+ var actualDistance = 0;
+ for (var delta in summary) {
+ actualDistance += delta.addedCount + delta.removed.length;
+ }
- expect(actualDistance, expectedDist);
- });
+ expect(actualDistance, expectedDist);
+ });
test('add items', () {
var model = toObservable([]);
« no previous file with comments | « packages/observable/pubspec.yaml ('k') | packages/observable/test/observable_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698