anchor.diff:      break;
     }
   }
  -''';
  -    CompilationUnit unit = await resolveSource(code);
  -    // re-resolve
  -    _cloneResolveUnit(unit);
  +''');
  +    await resolveTestFile();
  +    // re-resolve
  +    _cloneResolveUnit(result.unit);
       // no other validations than built into DeclarationResolver
     }
   
     test_closure_inside_switch_default() async {
  -    String code = '''
  +    addTestFile('''
   void f(k, m) {
     switch (k) {
       default:
  
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: 
    Future<void> setupCode(String code) async {
      this.code = code;
  
      addTestFile(code + ' const a = null;');
      await resolveTestFile();
  
      unit = result.unit;
      unit2 = _cloneResolveUnit(unit);
    }
  
    test_classDeclaration() async {
      await setupCode('@a class C {}');
      checkMetadata('C');
    }
  
    test_classTypeAlias() async {
      await setupCode('@a class C = D with E; class D {} class E {}');
      checkMetadata('C');
    }
  
    test_constructorDeclaration_named() async {
      await setupCode('class C { @a C.x(); }');
      checkMetadata('x');
    }
  
    test_constructorDeclaration_unnamed() async {
      await setupCode('class C { @a C(); }');
      checkMetadata('C()');
    }
  
    test_declaredIdentifier() async {
      await setupCode('f(x, y) { for (@a var x in y) {} }');
      checkMetadata('var', expectDifferent: true);
    }
  
    test_enumDeclaration() async {
      await setupCode('@a enum E { v }');
      checkMetadata('E');
    }
  
    test_enumDeclaration_constant() async {
      await setupCode('enum E { @a v }');
      checkMetadata('v');
    }
  
    test_exportDirective() async {
      newFile('/test/lib/foo.dart', content: 'class C {}');
      await setupCode('@a export "foo.dart";');
      checkMetadata('export');
    }
  
    test_exportDirective_resynthesized() async {
      addTestFile(r'''
  @a
  export "dart:async";
  
  