Bläddra i källkod

* extended test to include the test case for #40732

florian 1 år sedan
förälder
incheckning
6a109634b0
3 ändrade filer med 64 tillägg och 1 borttagningar
  1. 60 1
      tests/test/minmax.inc
  2. 2 0
      tests/test/tminmax1.pp
  3. 2 0
      tests/test/tminmax2.pp

+ 60 - 1
tests/test/minmax.inc

@@ -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.

+ 2 - 0
tests/test/tminmax1.pp

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

+ 2 - 0
tests/test/tminmax2.pp

@@ -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 }