Having a look at DunitLite (https://code.google.com/p/dunitlite/) and came across a compiling error under Delphi XE which I don't quite understand. The following class doesn't seem to play nice:

Having a look at DunitLite (https://code.google.com/p/dunitlite/) and came across a compiling error under Delphi XE which I don't quite understand. The following class doesn't seem to play nice:

  TSpecification = class(TInsulatedTest)
  strict protected type
    Given = Specifiers.Given;
    Should = Specifiers.Should;
    Specify = Specifiers.Specify;
  end;

When TSpecification.Should or any others are used, the compiler reports:

[DCC Fatal Error] ConstraintTests.pas(683): F2051 Unit ConstraintTests was compiled with a different version of Specifications.Should

However, if the following is used

  TSpecification = class(TInsulatedTest)
  strict protected type
    Given = class(Specifiers.Given);
    Should = class(Specifiers.Should);
    Specify = class(Specifiers.Specify);
  end;

It compiles fine. Dunitlite seems to be written for Delphi 2005+ (as it uses the for-in syntax) but breaks on Delphi 2010+.

Does anyone know why the second class definition needs to be used, as I thought the first class definition should be fine...?
https://code.google.com/p/dunitlite/

Comments

  1. My guess is that the linker resolves to Specifiers.Should while the compiler used TSpecification.Should (or vice versa). Anyway, the subclass fix works, I did the same. Also, cast all TypeInfo.Name to string() and change "Ch in [#0..#31]" into "(Ch >= #0) and (Ch <= #31)" to get it compiling without hints and warnings.

    ReplyDelete
  2. As a sidenote, there's a few hardcoded strings that introduce a problem with DecimalSeparator <> '.' Fix that by adding "FormatSettings.DecimalSeparator := '.'" to the initialization section of ValueComparers.pas
    ;)

    ReplyDelete
  3. Patrick van Logchem I also removed all the hints and warnings with the changes that you have done (those were easy compared to the compiler issue one).
    Thanks for the heads up about DecimalSeparator issue - thankfully I live in a place where DecimalSeparator = '.' :-)

    ReplyDelete

Post a Comment