| OLD | NEW | 
|    1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file |    1 // Copyright (c) 2013, 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 substitute_future_test; |    5 library substitute_future_test; | 
|    6  |    6  | 
|    7 import 'dart:async'; |    7 import 'dart:async'; | 
|    8  |    8  | 
|    9 import 'package:scheduled_test/src/substitute_future.dart'; |    9 import 'package:scheduled_test/src/substitute_future.dart'; | 
|   10 import 'package:unittest/unittest.dart'; |   10 import 'package:unittest/unittest.dart'; | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   24       completer.complete('success'); |   24       completer.complete('success'); | 
|   25     }); |   25     }); | 
|   26  |   26  | 
|   27     test('.asStream on error', () { |   27     test('.asStream on error', () { | 
|   28       expect(future.asStream().toList(), throwsA(equals('error'))); |   28       expect(future.asStream().toList(), throwsA(equals('error'))); | 
|   29       completer.completeError('error'); |   29       completer.completeError('error'); | 
|   30     }); |   30     }); | 
|   31  |   31  | 
|   32     test('.then and .catchError on success', () { |   32     test('.then and .catchError on success', () { | 
|   33       expect(future.then((v) => "transformed $v") |   33       expect(future.then((v) => "transformed $v") | 
|   34               .catchError((e) => "caught ${e.error}"), |   34               .catchError((error) => "caught ${error}"), | 
|   35           completion(equals('transformed success'))); |   35           completion(equals('transformed success'))); | 
|   36       completer.complete('success'); |   36       completer.complete('success'); | 
|   37     }); |   37     }); | 
|   38  |   38  | 
|   39     test('.then and .catchError on error', () { |   39     test('.then and .catchError on error', () { | 
|   40       expect(future.then((v) => "transformed $v") |   40       expect(future.then((v) => "transformed $v") | 
|   41               .catchError((e) => "caught ${e.error}"), |   41               .catchError((error) => "caught ${error}"), | 
|   42           completion(equals('caught error'))); |   42           completion(equals('caught error'))); | 
|   43       completer.completeError('error'); |   43       completer.completeError('error'); | 
|   44     }); |   44     }); | 
|   45  |   45  | 
|   46     test('.then with onError on success', () { |   46     test('.then with onError on success', () { | 
|   47       expect(future.then((v) => "transformed $v", |   47       expect(future.then((v) => "transformed $v", | 
|   48               onError: (e) => "caught ${e.error}"), |   48               onError: (error) => "caught ${error}"), | 
|   49           completion(equals('transformed success'))); |   49           completion(equals('transformed success'))); | 
|   50       completer.complete('success'); |   50       completer.complete('success'); | 
|   51     }); |   51     }); | 
|   52  |   52  | 
|   53     test('.then with onError on error', () { |   53     test('.then with onError on error', () { | 
|   54       expect(future.then((v) => "transformed $v", |   54       expect(future.then((v) => "transformed $v", | 
|   55               onError: (e) => "caught ${e.error}"), |   55               onError: (error) => "caught ${error}"), | 
|   56           completion(equals('caught error'))); |   56           completion(equals('caught error'))); | 
|   57       completer.completeError('error'); |   57       completer.completeError('error'); | 
|   58     }); |   58     }); | 
|   59  |   59  | 
|   60     test('.whenComplete on success', () { |   60     test('.whenComplete on success', () { | 
|   61       expect(future.whenComplete(() { |   61       expect(future.whenComplete(() { | 
|   62         throw 'whenComplete'; |   62         throw 'whenComplete'; | 
|   63       }), throwsA(equals('whenComplete'))); |   63       }), throwsA(equals('whenComplete'))); | 
|   64       completer.complete('success'); |   64       completer.complete('success'); | 
|   65     }); |   65     }); | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  145   }); |  145   }); | 
|  146  |  146  | 
|  147   test('substituting after a future has completed is an error', () { |  147   test('substituting after a future has completed is an error', () { | 
|  148     var completer = new Completer(); |  148     var completer = new Completer(); | 
|  149     var future = new SubstituteFuture(completer.future); |  149     var future = new SubstituteFuture(completer.future); | 
|  150     completer.complete('success'); |  150     completer.complete('success'); | 
|  151     expect(() => future.substitute(new Future.immediate(null)), |  151     expect(() => future.substitute(new Future.immediate(null)), | 
|  152         throwsStateError); |  152         throwsStateError); | 
|  153   }); |  153   }); | 
|  154 } |  154 } | 
| OLD | NEW |