Discussion:
Free Pascal/Delphi compatibility cross-tests
Add Reply
Dmitriy Pomerantsev
2017-03-25 22:49:25 UTC
Reply
Permalink
Raw Message
Hello everyone.

In my free time, I write a small (so far) set of tests to verify the compatibility of Delphi and Free Pascal. The main idea: Delphi has DUnit2, Free Pascal has fpcunit and it is partially compatible with DUnit2. Therefore, you can write tests that can be runned simultaneously in Delphi and Free Pascal.

The repository is located https://github.com/pda0/fp_cross_tests

Now there are not many ready-made tests. There are for TGuidHelper, TSingleHelper, TDoubleHelper and TExtendedHelper (I started with them, because it's not easy to test methods handling of floating point numbers). Write tests for the integer types will be easier.

Right now you can not just take Lazarus, trunk Free Pascal and run these tests. You will need a patches from the "patches" directory.

I myself ran tests on Windows 7 Delphi 10.2 Berlin Pro (i386 and x86_64), as well as on trunk Free Pascal 3.1.1 (i386 and x86_64). In addition, I ran them on Fedora 25 Linux (i386 and x86_64).

I need your opinion. Is it interesting to anyone besides me?

I need your help. I do not have access to a big endian machine and I don't know how correctly these tests will work there.

In addition, certain lines cause problems. In particular, lines

CheckException(BytesRangeOverflow, ERangeError);

and

CheckException(WordsRangeOverflow, ERangeError);

in files Test.SysUtils.TSingleHelper.pas, Test.SysUtils.TDoubleHelper.pas and Test.SysUtils.TExtendedHelper.pas are have to to test out of range situation. But despite the use of the SysUtils module, Free Pascal generates a runtime error, interrupting further execution of the tests. I still do not understand why.

If we temporarily remove them, we will see a number of problems.

1. Difference in implementation.
  For example, in Delphi, Exponent has a bias "For single precision floating-point values, the bias is 127." (http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SysUtils.TsingleHelper.Exponent), Free Pascal does not (http://www.freepascal.org/docs-html/rtl/sysutils/tsinglehelper.exponent.html).
  Delphi returns Mantissa with a hidden bit "Mantissa, also known as the significand, is the raw fraction part of the number with the 1 bit before it." (http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SysUtils.TsingleHelper.Mantissa), Free Pascal - does not "Mantissa is the value of the significand without the hidden bit." (http://www.freepascal.org/docs-html/rtl/sysutils/tsinglehelper.mantissa.html).

2. String handling differences. Free Pascal returns +Infinity as "+INF", Delphi as "INF". It can be important for programs that wait for certain literals. In addition, Free Pascal can convert literals "+INF", "-INF", "NAN" to floats, Delphi - does not. Some numbers are differently converted to strings. For example, 2.8E32 in Delphi turns into "2.8E32", and in Free Pascal is in "280000005400000000000000000000.00".

So what do you think?

Dmitriy Pomerantsev.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailma
Adriaan van Os
2017-03-28 12:39:46 UTC
Reply
Permalink
Raw Message
Post by Dmitriy Pomerantsev
Hello everyone.
1. Difference in implementation.
 For example, in Delphi, Exponent has a bias "For single precision floating-point values, the bias is 127." (http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SysUtils.TsingleHelper.Exponent), Free Pascal does not (http://www.freepascal.org/docs-html/rtl/sysutils/tsinglehelper.exponent.html).
This is certainly not true. The single floatomg-point format is determined by the IEEE-754
standard. And that format has indeed a bias of 127
<https://en.wikipedia.org/wiki/Single-precision_floating-point_format> for any compiler.

Regards,

Adriaian van Os
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/list
Adriaan van Os
2017-03-28 12:56:14 UTC
Reply
Permalink
Raw Message
Post by Adriaan van Os
Post by Dmitriy Pomerantsev
Hello everyone.
1. Difference in implementation.
 For example, in Delphi, Exponent has a bias "For single precision floating-point values, the bias is 127." (http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SysUtils.TsingleHelper.Exponent), Free Pascal does not (http://www.freepascal.org/docs-html/rtl/sysutils/tsinglehelper.exponent.html).
This is certainly not true. The single floatomg-point format is determined by the IEEE-754
standard. And that format has indeed a bias of 127
<https://en.wikipedia.org/wiki/Single-precision_floating-point_format> for any compiler.
Or did you mean the Exponent function-return, not the internal format ? Then, my comment above is
wrong. Anyway, I feel that compilers should follow the IEE-754 and ISO/IEC 10967
<https://en.wikipedia.org/wiki/ISO/IEC_10967> standards.

Regards,

Adriaan van Os

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepasca

Loading...