浏览代码

+ inline01.pp inline test

Jonas Maebe 25 年之前
父节点
当前提交
b440e794b6
共有 2 个文件被更改,包括 125 次插入0 次删除
  1. 121 0
      tests/test/inline01.pp
  2. 4 0
      tests/test/readme.txt

+ 121 - 0
tests/test/inline01.pp

@@ -0,0 +1,121 @@
+program inline01;
+
+var
+  starti: longint;
+  i:longint;
+
+
+{$INLINE ON}
+
+procedure kkainl(var c: longint); inline;
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  writeln('kka ',c);
+  c:=c+1;
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+end;
+
+procedure kka(var c:longint);
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  writeln('kka ',c);
+  c:=c+1;
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+end;
+
+procedure kkb(var c:longint);inline;
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  kka(c);
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  writeln('kkb ',c);
+end;
+
+procedure kkb2(var c:longint);inline;
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  kkainl(c);
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  writeln('kkb ',c);
+end;
+
+procedure kkc(var c: longint);
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  kkb(c);
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+end;
+
+procedure kkcinl(var c: longint); inline;
+begin
+  if c <> starti then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+  kkb2(c);
+  if i <> starti+1 then
+    begin
+      writeln('bug');
+      halt(1);
+    end;
+end;
+
+begin
+  i:=5;
+  starti := 5;
+  kkc(i);
+  starti := i;
+  kkc(i);
+  starti := i;
+  kkb(i);
+  starti := i;
+  kkb(i);
+  starti := i;
+  kka(i);
+  starti := i;
+  kkcinl(i);
+  starti := i;
+  kkb2(i);
+end.
+

+ 4 - 0
tests/test/readme.txt

@@ -32,3 +32,7 @@ case .................. testcase.pp    tests case statements with byte and word
 Arrays ................ testarr1.pp    small test for open arrays with classes
 Arrays ................ testarr1.pp    small test for open arrays with classes
 Enumerations .......... testenm1.pp    tests assignments of subrange
 Enumerations .......... testenm1.pp    tests assignments of subrange
                                        enumerations
                                        enumerations
+Inline ................ inline01.pp    tests recursive inlining, inlining
+                                       a procedure multiple times and
+                                       inlining procedures in other
+                                       inline procedures.