anchor.diff:  }
   ''';
       _resolveTestUnit(code);
  -
  -    SimpleIdentifier identifier = _findIdentifier('foo');
  -    VariableDeclaration declaration =
  -        identifier.getAncestor((node) => node is VariableDeclaration);
  -    expect(declaration.initializer.staticType.name, 'int');
  -    expect(declaration.initializer.propagatedType, isNull);
  +    _expectInitializerType('foo', 'int', isNull);
     }
   
     void test_dynamicObjectMethod_toString() {
  
positive.code: """;
      _resolveTestUnit(code);
      // "foo" should be resolved to the "Foo" type
      SimpleIdentifier identifier = _findIdentifier("foo();");
      DartType type = identifier.staticType;
      expect(type, new isInstanceOf<FunctionType>());
    }
  
    void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
  
negative.code:     return identifier;
    }
  
    /**
     * Looks up the identifier with [name] and validates its static [type].
     *
     * If [type] is a string, validates that the identifier's static type
     * stringifies to that text. Otherwise, [type] is used directly a [Matcher]
     * to match the type.
     *
     * If [propagatedType] is given, also validate's the identifier's propagated
     * type.
     */
    void _expectIdentifierType(String name, type, [propagatedType]) {
      SimpleIdentifier identifier = _findIdentifier(name);
      _expectType(identifier.staticType, type);
      if (propagatedType != null) {
        _expectType(identifier.propagatedType, propagatedType);
      }
    }
  
    /**
     * Looks up the initializer for the declaration containing [identifier] and
     * validates its static [type].
     *
     * If [type] is a string, validates that the identifier's static type
     * stringifies to that text. Otherwise, [type] is used directly a [Matcher]
     * to match the type.
     *
     * If [propagatedType] is given, also validate's the identifier's propagated
     * type.
     */
    void _expectInitializerType(String name, type, [propagatedType]) {
      SimpleIdentifier identifier = _findIdentifier(name);
      VariableDeclaration declaration =
          identifier.getAncestor((node) => node is VariableDeclaration);
      Expression initializer = declaration.initializer;
      _expectType(initializer.staticType, type);
      if (propagatedType != null) {
        _expectType(initializer.propagatedType, propagatedType);
      }
    }
  
    /**
     * Looks up the identifier with [name] and validates that its type type
     * stringifies to [type] and that its generics match the given stringified
     * output.
     */
    _expectFunctionType(String name, String type,
        {String elementTypeParams: '[]',
        String typeParams: '[]',
        String typeArgs: '[]',
        String typeFormals: '[]'}) {
      SimpleIdentifier identifier = _findIdentifier(name);
      // Element is either ExecutableElement or ParameterElement.
      var element = identifier.staticElement;
      FunctionTypeImpl functionType = identifier.staticType;
      expect(functionType.toString(), type);
      expect(element.typeParameters.toString(), elementTypeParams);
      expect(functionType.typeParameters.toString(), typeParams);
      expect(functionType.typeArguments.toString(), typeArgs);
      expect(functionType.typeFormals.toString(), typeFormals);
    }
  
    /**
     * Validates that [type] matches [expected].
     *
     * If [expected] is a string, validates that the type stringifies to that
     * text. Otherwise, [expected] is used directly a [Matcher] to match the type.
     */
    _expectType(DartType type, expected) {
      if (expected is String) {
        expect(type.toString(), expected);
      } else {
        expect(type, expected);
      }
    }
  
    void _resolveTestUnit(String code) {
      testCode = code;
      testSource = addSource(testCode);
  