Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit 02a609b

Browse files
committed
Merge pull request #84 from dart-lang/test-package
update to the test package
2 parents 5197403 + 4a8083d commit 02a609b

11 files changed

+62
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### 0.13.3
2+
3+
* Update to the `test` package.
4+
15
#### 0.13.2
26

37
* Update to analyzer '^0.27.0'.

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: observe
2-
version: 0.13.2
2+
version: 0.13.3
33
author: Polymer.dart Authors <[email protected]>
44
description: >
55
Observable properties and objects for use in template_binding.
@@ -22,7 +22,7 @@ dev_dependencies:
2222
benchmark_harness: '>=1.0.0 <2.0.0'
2323
browser: any
2424
chart: '>=1.0.8 <2.0.0'
25-
unittest: '>=0.10.0 <0.12.0'
25+
test: '^0.12.0'
2626
stack_trace: '>=0.9.1 <2.0.0'
2727
environment:
2828
sdk: '>=1.8.0 <2.0.0'

test/list_change_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
import 'dart:async';
66
import 'package:observe/observe.dart';
7-
import 'package:unittest/unittest.dart';
87
import 'observe_test_utils.dart';
98

109
// This file contains code ported from:
1110
// https://github.com/rafaelw/ChangeSummary/blob/master/tests/test.js
1211

13-
main() => dirtyCheckZone().run(listChangeTests);
12+
main() => listChangeTests();
1413

1514
// TODO(jmesserly): port or write array fuzzer tests
1615
listChangeTests() {

test/list_path_observer_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:async';
66
import 'package:observe/observe.dart';
7-
import 'package:unittest/unittest.dart';
87
import 'observe_test_utils.dart';
98

109
import 'package:observe/mirrors_used.dart' as mu; // make test smaller.

test/observable_list_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
import 'dart:async';
66
import 'package:observe/observe.dart';
7-
import 'package:unittest/unittest.dart';
87
import 'observe_test_utils.dart';
98

10-
main() => dirtyCheckZone().run(_runTests);
9+
main() => _runTests();
1110

1211
_runTests() {
1312
// TODO(jmesserly): need all standard List API tests.

test/observable_map_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
import 'dart:async';
66
import 'package:observe/observe.dart';
7-
import 'package:unittest/unittest.dart';
87
import 'observe_test_utils.dart';
98

10-
main() => dirtyCheckZone().run(_runTests);
9+
main() => _runTests();
1110

1211
_runTests() {
1312
// TODO(jmesserly): need all standard Map API tests.

test/observe_test.dart

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:async';
66
import 'package:logging/logging.dart';
77
import 'package:observe/observe.dart';
88
import 'package:observe/src/dirty_check.dart' as dirty_check;
9-
import 'package:unittest/unittest.dart';
109
import 'observe_test_utils.dart';
1110

1211
import 'package:observe/mirrors_used.dart' as mu; // make test smaller.
@@ -15,7 +14,7 @@ import 'package:smoke/mirrors.dart';
1514
/// Uses [mu].
1615
main() {
1716
useMirrors();
18-
dirtyCheckZone().run(_tests);
17+
_tests();
1918
}
2019

2120
void _tests() {
@@ -50,8 +49,9 @@ void _tests() {
5049
var maxNumIterations = dirty_check.MAX_DIRTY_CHECK_CYCLES;
5150

5251
var x = new WatcherModel(0);
53-
var sub = x.changes.listen(expectAsync((_) { x.value++; },
54-
count: maxNumIterations));
52+
var sub = x.changes.listen(expectAsync((_) {
53+
x.value++;
54+
}, count: maxNumIterations));
5555
x.value = 1;
5656
Observable.dirtyCheck();
5757
expect(x.value, maxNumIterations + 1);
@@ -89,7 +89,7 @@ void _observeTests(createModel(x)) {
8989
});
9090

9191
test('handle future result', () {
92-
var callback = expectAsync((){});
92+
var callback = expectAsync(() {});
9393
return new Future(callback);
9494
});
9595

@@ -144,7 +144,7 @@ void _observeTests(createModel(x)) {
144144

145145
verifyRecords(records) {
146146
expectPropertyChanges(records, watch ? 1 : 2);
147-
};
147+
}
148148

149149
subs.add(t.changes.listen(expectAsync(verifyRecords)));
150150
subs.add(t.changes.listen(expectAsync(verifyRecords)));
@@ -156,7 +156,9 @@ void _observeTests(createModel(x)) {
156156
test('async processing model', () {
157157
var t = createModel(123);
158158
var records = [];
159-
subs.add(t.changes.listen((r) { records.addAll(r); }));
159+
subs.add(t.changes.listen((r) {
160+
records.addAll(r);
161+
}));
160162
t.value = 41;
161163
t.value = 42;
162164
expectChanges(records, [], reason: 'changes delived async');
@@ -167,7 +169,6 @@ void _observeTests(createModel(x)) {
167169

168170
t.value = 777;
169171
expectChanges(records, [], reason: 'changes delived async');
170-
171172
}).then(newMicrotask).then((_) {
172173
expectPropertyChanges(records, 1);
173174

@@ -210,7 +211,9 @@ void _observeTests(createModel(x)) {
210211
test('cannot modify changes list', () {
211212
var t = createModel(123);
212213
var records = null;
213-
subs.add(t.changes.listen((r) { records = r; }));
214+
subs.add(t.changes.listen((r) {
215+
records = r;
216+
}));
214217
t.value = 42;
215218

216219
return new Future(() {
@@ -222,16 +225,22 @@ void _observeTests(createModel(x)) {
222225
records[0] = new PropertyChangeRecord(t, #value, 0, 1);
223226
}, throwsUnsupportedError);
224227

225-
expect(() { records.clear(); }, throwsUnsupportedError);
228+
expect(() {
229+
records.clear();
230+
}, throwsUnsupportedError);
226231

227-
expect(() { records.length = 0; }, throwsUnsupportedError);
232+
expect(() {
233+
records.length = 0;
234+
}, throwsUnsupportedError);
228235
});
229236
});
230237

231238
test('notifyChange', () {
232239
var t = createModel(123);
233240
var records = [];
234-
subs.add(t.changes.listen((r) { records.addAll(r); }));
241+
subs.add(t.changes.listen((r) {
242+
records.addAll(r);
243+
}));
235244
t.notifyChange(new PropertyChangeRecord(t, #value, 123, 42));
236245

237246
return new Future(() {
@@ -243,7 +252,9 @@ void _observeTests(createModel(x)) {
243252
test('notifyPropertyChange', () {
244253
var t = createModel(123);
245254
var records = null;
246-
subs.add(t.changes.listen((r) { records = r; }));
255+
subs.add(t.changes.listen((r) {
256+
records = r;
257+
}));
247258
expect(t.notifyPropertyChange(#value, t.value, 42), 42,
248259
reason: 'notifyPropertyChange returns newValue');
249260

@@ -257,10 +268,10 @@ void _observeTests(createModel(x)) {
257268
expectPropertyChanges(records, int number) {
258269
expect(records.length, number, reason: 'expected $number change records');
259270
for (var record in records) {
260-
expect(record is PropertyChangeRecord, true, reason:
261-
'record should be PropertyChangeRecord');
262-
expect((record as PropertyChangeRecord).name, #value, reason:
263-
'record should indicate a change to the "value" property');
271+
expect(record is PropertyChangeRecord, true,
272+
reason: 'record should be PropertyChangeRecord');
273+
expect((record as PropertyChangeRecord).name, #value,
274+
reason: 'record should indicate a change to the "value" property');
264275
}
265276
}
266277

test/observe_test_utils.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,27 @@ library observe.test.observe_test_utils;
77
import 'dart:async';
88
import 'package:observe/observe.dart';
99
import 'package:observe/mirrors_used.dart' as mu; // to make tests smaller
10-
import 'package:unittest/unittest.dart';
10+
import 'package:observe/src/dirty_check.dart';
11+
import 'package:test/test.dart' hide test, group, setUp, tearDown;
12+
import 'package:test/test.dart' as original_test
13+
show test, group, setUp, tearDown;
14+
1115
export 'package:observe/src/dirty_check.dart' show dirtyCheckZone;
16+
export 'package:test/test.dart' hide test, group, setUp, tearDown;
17+
18+
/// Custom implementations of the functions from `package:test`. These ensure
19+
/// that the body of all test function are run in the dirty checking zone.
20+
test(String description, body()) => original_test.test(
21+
description, () => dirtyCheckZone().bindCallback(body)());
22+
23+
group(String description, body()) => original_test.group(
24+
description, () => dirtyCheckZone().bindCallback(body)());
25+
26+
setUp(body()) =>
27+
original_test.setUp(() => dirtyCheckZone().bindCallback(body)());
28+
29+
tearDown(body()) =>
30+
original_test.tearDown(() => dirtyCheckZone().bindCallback(body)());
1231

1332
/// A small method to help readability. Used to cause the next "then" in a chain
1433
/// to happen in the next microtask:

test/path_observer_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:async';
66
import 'package:observe/observe.dart';
7-
import 'package:unittest/unittest.dart';
87
import 'package:observe/src/path_observer.dart'
98
show getSegmentsOfPropertyPathForTesting,
109
observerSentinelForTesting;
@@ -21,7 +20,7 @@ import 'package:smoke/mirrors.dart';
2120
// the tests below.
2221
//
2322
/// Uses [mu].
24-
main() => dirtyCheckZone().run(() {
23+
main() {
2524
useMirrors();
2625

2726
group('PathObserver', observePathTests);
@@ -148,7 +147,7 @@ main() => dirtyCheckZone().run(() {
148147
});
149148

150149
group('CompoundObserver', compoundObserverTests);
151-
});
150+
}
152151

153152
observePathTests() {
154153
test('Degenerate Values', () {

test/transformer_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
4+
@TestOn('vm')
45
import 'dart:async';
56
import 'package:barback/barback.dart';
67
import 'package:observe/transformer.dart';
7-
import 'package:unittest/compact_vm_config.dart';
8-
import 'package:unittest/unittest.dart';
98
import 'package:stack_trace/stack_trace.dart';
9+
import 'package:test/test.dart';
1010

1111
main() {
12-
useCompactVMConfiguration();
13-
1412
group('replaces Observable for ChangeNotifier', () {
1513
_testClause('extends Observable', 'extends ChangeNotifier');
1614
_testClause('extends Base with Observable',

0 commit comments

Comments
 (0)