anchor.diff:  const a = null;
   const b = null;
   ''');
  +    await resolveTestFile();
  +    unit = result.unit;
  +
       expect(unit.directives[0].metadata.single.name.name, 'a');
       expect(unit.directives[1].metadata.single.name.name, 'b');
       var unitElement = unit.declaredElement as CompilationUnitElementImpl;
  +
       // Damage the unit element - as if "setAnnotations" were not called.
       // The ImportElement(s) still have the metadata, we should use it.
       unitElement.setAnnotations(unit.directives[0].offset, []);
       unitElement.setAnnotations(unit.directives[1].offset, []);
       expect(unitElement.library.imports[0].metadata, hasLength(1));
       expect(unitElement.library.imports[1].metadata, hasLength(1));
  +
       // DeclarationResolver on the clone should succeed.
       CompilationUnit clonedUnit = AstCloner.clone(unit);
       new DeclarationResolver().resolve(clonedUnit, unit.declaredElement);
  
positive.code:   return clonedUnit;
  }
  
  SimpleIdentifier _findSimpleIdentifier(
      AstNode root, String code, String search) {
    return EngineTestCase.findNode(
        root, code, search, (n) => n is SimpleIdentifier);
  }
  
  /// TODO(paulberry): migrate this test away from the task model.
  /// See dartbug.com/35734.
  @reflectiveTest
  class DeclarationResolverMetadataTest extends ResolverTestCase {
    String code;
    CompilationUnit unit;
    CompilationUnit unit2;
  
negative.code:     expect(unit.directives[2].metadata.single.name.name, 'b');
    }
  
    test_simpleFormalParameter() async {
      await setupCode('f(@a x) {}) {}');
      checkMetadata('x');
    }
  
    test_simpleFormalParameter_withDefault() async {
      await setupCode('f([@a x = null]) {}');
      checkMetadata('x');
    }
  
    test_topLevelVariableDeclaration() async {
      await setupCode('@a int x;');
      checkMetadata('x');
    }
  
    test_typeParameter_ofClass() async {
      await setupCode('class C<@a T> {}');
      checkMetadata('T');
    }
  
    test_typeParameter_ofClassTypeAlias() async {
      await setupCode('class C<@a T> = D with E; class D {} class E {}');
      checkMetadata('T');
    }
  
    test_typeParameter_ofFunction() async {
      await setupCode('f<@a T>() {}');
      checkMetadata('T');
    }
  
    test_typeParameter_ofTypedef() async {
      await setupCode('typedef F<@a T>();');
      checkMetadata('T');
    }
  