OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library unittest.test.utils; | 5 library unittest.test.utils; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:unittest/src/backend/invoker.dart'; | 10 import 'package:unittest/src/backend/invoker.dart'; |
11 import 'package:unittest/src/backend/live_test.dart'; | 11 import 'package:unittest/src/backend/live_test.dart'; |
12 import 'package:unittest/src/backend/state.dart'; | 12 import 'package:unittest/src/backend/state.dart'; |
13 import 'package:unittest/src/backend/suite.dart'; | 13 import 'package:unittest/src/backend/suite.dart'; |
14 import 'package:unittest/src/runner/load_exception.dart'; | 14 import 'package:unittest/src/runner/load_exception.dart'; |
15 import 'package:unittest/src/util/remote_exception.dart'; | 15 import 'package:unittest/src/util/remote_exception.dart'; |
16 import 'package:unittest/unittest.dart'; | 16 import 'package:unittest/unittest.dart'; |
17 | 17 |
| 18 /// The string representation of an untyped closure with no arguments. |
| 19 /// |
| 20 /// This differs between dart2js and the VM. |
| 21 final String closureString = (() {}).toString(); |
| 22 |
18 // The last state change detected via [expectStates]. | 23 // The last state change detected via [expectStates]. |
19 State lastState; | 24 State lastState; |
20 | 25 |
21 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange]. | 26 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange]. |
22 /// | 27 /// |
23 /// The most recent emitted state is stored in [_lastState]. | 28 /// The most recent emitted state is stored in [_lastState]. |
24 void expectStates(LiveTest liveTest, Iterable<State> statesIter) { | 29 void expectStates(LiveTest liveTest, Iterable<State> statesIter) { |
25 var states = new Queue.from(statesIter); | 30 var states = new Queue.from(statesIter); |
26 liveTest.onStateChange.listen(expectAsync((state) { | 31 liveTest.onStateChange.listen(expectAsync((state) { |
27 lastState = state; | 32 lastState = state; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 }); | 237 }); |
233 }); | 238 }); |
234 | 239 |
235 return liveTest.run().then((_) { | 240 return liveTest.run().then((_) { |
236 expectTestPassed(liveTest); | 241 expectTestPassed(liveTest); |
237 // Ensure that the outer test doesn't complete until the inner future | 242 // Ensure that the outer test doesn't complete until the inner future |
238 // completes. | 243 // completes. |
239 return future; | 244 return future; |
240 }); | 245 }); |
241 } | 246 } |
OLD | NEW |