anchor.diff:  ''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
   part 'bar.dart';
   class C { }
  -''', adjustValidUnitBeforeComparison: (CompilationUnit unit) {
  -      unit.beginToken = unit.declarations[0].beginToken;
  -      return unit;
  -    });
  +''', adjustValidUnitBeforeComparison: _updateBeginToken);
     }
   
     void test_declarationBeforeDirective_part_of() {
  
positive.code: ''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
  export 'bar.dart';
  class C { }
  ''', adjustValidUnitBeforeComparison: (CompilationUnit unit) {
        unit.beginToken = unit.declarations[0].beginToken;
        return unit;
      });
    }
  
    void test_declarationBeforeDirective_import() {
  
negative.code: ''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
  part of foo;
  class C { }
  ''', adjustValidUnitBeforeComparison: _updateBeginToken);
    }
  
    void test_exportBeforeLibrary() {
      testRecovery('''
  export 'bar.dart';
  library l;
  ''', [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST], '''
  library l;
  export 'bar.dart';
  ''', adjustValidUnitBeforeComparison: _moveFirstDirectiveToEnd);
    }
  
    void test_importBeforeLibrary() {
      testRecovery('''
  import 'bar.dart';
  library l;
  ''', [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST], '''
  library l;
  import 'bar.dart';
  ''', adjustValidUnitBeforeComparison: _moveFirstDirectiveToEnd);
    }
  
    void test_partBeforeExport() {
      testRecovery('''
  part 'foo.dart';
  export 'bar.dart';
  ''', [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE], '''
  export 'bar.dart';
  part 'foo.dart';
  ''', adjustValidUnitBeforeComparison: _moveFirstDirectiveToEnd);
    }
  
    void test_partBeforeImport() {
      testRecovery('''
  part 'foo.dart';
  import 'bar.dart';
  ''', [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE], '''
  import 'bar.dart';
  part 'foo.dart';
  ''', adjustValidUnitBeforeComparison: _moveFirstDirectiveToEnd);
    }
  
    void test_partBeforeLibrary() {
      testRecovery('''
  part 'foo.dart';
  library l;
  ''', [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST], '''
  library l;
  part 'foo.dart';
  ''', adjustValidUnitBeforeComparison: _moveFirstDirectiveToEnd);
    }
  
    CompilationUnit _moveFirstDirectiveToEnd(CompilationUnit unit) {
      unit.directives.add(unit.directives.removeAt(0));
      unit.beginToken = unit.directives[0].beginToken;
      return unit;
    }
  
    CompilationUnit _updateBeginToken(CompilationUnit unit) {
      unit.beginToken = unit.declarations[0].beginToken;
      return unit;
    }
  }
  
  