* extended test to include the test case for

This commit is contained in:
florian 2024-04-27 18:30:36 +02:00
parent e601156b8c
commit 6a109634b0
3 changed files with 64 additions and 1 deletions

View File

@ -1,4 +1,3 @@
{$mode objfpc}
uses
Math;
@ -642,10 +641,70 @@ procedure TestLongint;
TestFail(338);
end;
var
v1,v3 : Longint;
function Min1: Longint; inline;
begin
if v1 < v3 then
Result := v1
else
Result := v3;
end;
function Max1: Longint; inline;
begin
if v1 > v3 then
Result := v1
else
Result := v3;
end;
var
c1 : Longint = 1;
c3 : Longint = 3;
function Min11: Longint; inline;
begin
if c1 < c3 then
Result := c1
else
Result := c3;
end;
function Max11: Longint; inline;
begin
if c1 > c3 then
Result := c1
else
Result := c3;
end;
procedure TestLongintGlobal;
begin
v1:=1;
v3:=3;
if Min1<>1 then
TestFail(1301);
if Max1<>3 then
TestFail(1302);
if Min11<>1 then
TestFail(1311);
if Max11<>3 then
TestFail(1312);
end;
begin
TestSingle;
TestDouble;
TestDWord;
TestLongint;
TestLongintGlobal;
WriteLn('ok');
end.

View File

@ -1,2 +1,4 @@
{ %opt=-O- -O1 } { ensure we test code generation without constant propagation }
{$mode objfpc}
{$I minmax.inc }

View File

@ -1,3 +1,5 @@
{ %opt=-Oonofastmath -O3 } { with fast math, the operands of min/max might be swapped and this breaks the tests using NaN,
but test constant propagation and thus simplification }
{$mode objfpc}
{$I minmax.inc }