Forráskód Böngészése

+ new test for in64 value parameter push inlined

pierre 24 éve
szülő
commit
42035e7283
2 módosított fájl, 42 hozzáadás és 0 törlés
  1. 2 0
      tests/test/README
  2. 40 0
      tests/test/tinlin64.pp

+ 2 - 0
tests/test/README

@@ -43,6 +43,8 @@ Inline ................ tinline1.pp    tests recursive inlining, inlining
                                        a procedure multiple times and
                                        inlining procedures in other
                                        inline procedures.
+			tinlin64.pp    tests for a problem in pushing 64bit parameters
+				       by value.	
 TypeInfo .............. trtti2.pp      test the function system.typeinfo
                         trtti3.pp      tests the procedure system.finalize
 Resourcestrings ....... tresstr.pp     tests a simple resource string

+ 40 - 0
tests/test/tinlin64.pp

@@ -0,0 +1,40 @@
+program test_64bit_inline;
+
+{$inline on}
+
+function add (a,b : int64) : int64;
+begin
+  add:=a+b;
+end;
+
+function inlineadd (a,b : int64) : int64; inline;
+begin
+  inlineadd:=a+b;
+end;
+
+
+var
+  a, b, c, d : int64;
+
+begin
+  a:=50;
+  b:=78;
+  d:= -45;
+  writeln('a (',a,') + b (',b,') = ',a+b);
+  writeln('Using add function');
+  writeln('a (',a,') + b (',b,') = ',add(a+1,b-1));
+  writeln('Using add function inlined');
+  writeln('a (',a,') + b (',b,') = ',inlineadd(a+1,b-1));
+  c:=inlineadd(a+d,b-d);
+  writeln('a (',a,') + b (',b,') = ',c);
+  if (a+b<>add(a-1,b+1)) then
+    begin
+      writeln('Error in function with int64 args');
+      Halt(1);
+    end;
+  if (a+b<>inlineadd(a+1,b-1)) then
+    begin
+      writeln('Error in inlined function with int64 args');
+      Halt(1);
+    end;
+end.