fpc/tests/test/jvm/tstrreal2.pp
Jonas Maebe d4b6406e62 * fixed compilation of new str<->float code on the JVM target (patch by
Max Nazhalov) and use that code by default on the JVM target
  * adapted JVM tests for the new str<->float code similar to how the
    generic tests were adapted

git-svn-id: trunk@25954 -
2013-11-06 16:13:50 +00:00

63 lines
1.4 KiB
ObjectPascal

program tstrreal2;
{$ifdef cpujvm}
uses
{$ifdef java}jdk15{$else}androidr14{$endif};
{$macro on}
{$define write:=JLSystem.fout.print}
{$define writeln:=JLSystem.fout.println}
{$endif}
const
s: array[1..21] of string =
('10.00000000000000000',
'1.00000000000000000',
{$ifdef FPC_HAS_TYPE_EXTENDED}
'0.10000000000000000',
{$else FPC_HAS_TYPE_EXTENDED}
'0.10000000000000001',
{$endif FPC_HAS_TYPE_EXTENDED}
'0.01000000000000000',
'0.00100000000000000',
'0.00010000000000000',
'0.00001000000000000',
'0.00000100000000000',
'0.00000010000000000',
'0.00000001000000000',
'0.00000000100000000',
'0.00000000010000000',
'0.00000000001000000',
'0.00000000000100000',
'0.00000000000010000',
'0.00000000000001000',
'0.00000000000000100',
'0.00000000000000010',
'0.00000000000000001',
'0.00000000000000000',
'0.00000000000000000');
var
e: extended;
c: longint;
s2: string;
lenadjust: longint;
begin
if sizeof(extended) = 8 then
lenadjust := 0
else
lenadjust := 0;
e := 10.0;
for c := 1 to 21 do
begin
str(e:0:17,s2);
writeln(s2);
if s2 <> copy(s[c],1,length(s[c])-lenadjust) then
begin
write(' Error, should be '); writeln(copy(s[c],1,length(s[c])-lenadjust));
halt(1);
end;
e := e / 10.0;
end;
end.