anchor.diff:      );
       logger.printStatus('message');
       logger.printError('error message');
  -    await stdoutCompleter.future;
  -    await stderrCompleter.future;
  -    expect(stdoutThrew, true);
  -    expect(stderrThrew, true);
  +
  +    await stdout.done;
  +    await stderr.done;
     });
   
     testWithoutContext('Logger does not throw when stdio completes done with an error', () async {
  -    final MockStdout stdout = MockStdout();
  -    final MockStdout stderr = MockStdout();
  +    final FakeStdout stdout = FakeStdout(syncError: false, completeWithError: true);
  +    final FakeStdout stderr = FakeStdout(syncError: false, completeWithError: true);
       final Stdio stdio = Stdio.test(stdout: stdout, stderr: stderr);
  -    final Completer<void> stdoutError = Completer<void>();
  -    final Completer<void> stderrError = Completer<void>();
  -    final Completer<void> stdoutCompleter = Completer<void>();
  -    final Completer<void> stderrCompleter = Completer<void>();
  -    when(stdout.write(any)).thenAnswer((_) {
  -      Zone.current.runUnaryGuarded<void>((_) {
  -        stdoutError.completeError(Exception('Some pipe error'));
  -        stdoutCompleter.complete();
  -      }, null);
  -    });
  -    when(stderr.write(any)).thenAnswer((_) {
  -      Zone.current.runUnaryGuarded<void>((_) {
  -        stderrError.completeError(Exception('Some pipe error'));
  -        stderrCompleter.complete();
  -      }, null);
  -    });
  -    when(stdout.done).thenAnswer((_) => stdoutError.future);
  -    when(stderr.done).thenAnswer((_) => stderrError.future);
       final Logger logger = StdoutLogger(
         terminal: AnsiTerminal(
           stdio: stdio,
  
positive.code: final String bold = RegExp.escape(AnsiTerminal.bold);
  final String resetBold = RegExp.escape(AnsiTerminal.resetBold);
  final String resetColor = RegExp.escape(AnsiTerminal.resetColor);
  
  class MockStdout extends Mock implements Stdout {}
  
  void main() {
    testWithoutContext('correct logger instance is created', () {
  
negative.code: /// to [FakeLogger].
  Matcher _throwsInvocationFor(dynamic Function() fakeCall) =>
    throwsA(_matchesInvocation(_invocationFor(fakeCall)));
  
  class FakeStdout extends Fake implements Stdout {
    FakeStdout({@required this.syncError, this.completeWithError = false});
  
    final bool syncError;
    final bool completeWithError;
    final Completer<void> _completer = Completer<void>();
  
    @override
    void write(Object object) {
      if (syncError) {
        throw 'Error!';
      }
      Zone.current.runUnaryGuarded<void>((_) {
        if (completeWithError) {
          _completer.completeError(Exception('Some pipe error'));
        } else {
          _completer.complete();
          throw 'Error!';
        }
      }, null);
    }
  
    @override
    Future<void> get done => _completer.future;
  }
  