瀏覽代碼

test: ppus: test compile when unit changed

mattias 2 周之前
父節點
當前提交
1d73f6ec04

+ 16 - 0
tests/tppu/changeinner1/changeinner1_bird.pas

@@ -0,0 +1,16 @@
+unit changeinner1_bird;
+
+{$mode objfpc}
+
+interface
+
+function Fly(w : word): word;
+
+implementation
+
+function Fly(w : word): word;
+begin
+  Result := 5*w; // changed
+end;
+
+end.

+ 7 - 0
tests/tppu/changeinner1/changeinner1_prg.pas

@@ -0,0 +1,7 @@
+{$mode objfpc}
+
+uses changeinner1_ant;
+
+begin
+  writeln(Crawl(2));
+end.

+ 1 - 0
tests/tppu/changeinner1/ppus/.gitignore

@@ -0,0 +1 @@
+changeinner1_prg

+ 18 - 0
tests/tppu/changeinner1/src1/changeinner1_ant.pas

@@ -0,0 +1,18 @@
+unit changeinner1_ant;
+
+{$mode objfpc}
+
+interface
+
+uses changeinner1_bird;
+
+function Crawl(w : word): word;
+
+implementation
+
+function Crawl(w : word): word;
+begin
+  Result := Fly(w*2);
+end;
+
+end.

+ 18 - 0
tests/tppu/changeinner1/src2/changeinner1_ant.pas

@@ -0,0 +1,18 @@
+unit changeinner1_ant;
+
+{$mode objfpc}
+
+interface
+
+uses changeinner1_bird;
+
+function Crawl(w : word): word;
+
+implementation
+
+function Crawl(w : word): word;
+begin
+  Result := 7 * Fly(w); // changed
+end;
+
+end.

+ 18 - 0
tests/tppu/changeleaf1/changeleaf1_ant.pas

@@ -0,0 +1,18 @@
+unit changeleaf1_ant;
+
+{$mode objfpc}
+
+interface
+
+uses changeleaf1_bird;
+
+function Crawl(w : word): word;
+
+implementation
+
+function Crawl(w : word): word;
+begin
+  Result := Fly(w*2);
+end;
+
+end.

+ 7 - 0
tests/tppu/changeleaf1/changeleaf1_prg.pas

@@ -0,0 +1,7 @@
+{$mode objfpc}
+
+uses changeleaf1_ant;
+
+begin
+  writeln(Crawl(2));
+end.

+ 1 - 0
tests/tppu/changeleaf1/ppus/.gitignore

@@ -0,0 +1 @@
+changeleaf1_prg

+ 16 - 0
tests/tppu/changeleaf1/src1/changeleaf1_bird.pas

@@ -0,0 +1,16 @@
+unit changeleaf1_bird;
+
+{$mode objfpc}
+
+interface
+
+function Fly(w : word): word;
+
+implementation
+
+function Fly(w : word): word;
+begin
+  Result:=w*7;
+end;
+
+end.

+ 16 - 0
tests/tppu/changeleaf1/src2/changeleaf1_bird.pas

@@ -0,0 +1,16 @@
+unit changeleaf1_bird;
+
+{$mode objfpc}
+
+interface
+
+function Fly(w : word): word;
+
+implementation
+
+function Fly(w : word): word;
+begin
+  Result := 5*w; // changed
+end;
+
+end.

+ 7 - 0
tests/tppu/implinline3/implinline3_prg.pas

@@ -0,0 +1,7 @@
+{$mode objfpc}
+
+uses implinline3_ant;
+
+begin
+  writeln(times123(2));
+end.

+ 1 - 0
tests/tppu/implinline3/ppus/.gitignore

@@ -0,0 +1 @@
+implinline3_prg

+ 18 - 0
tests/tppu/implinline3/src1/implinline3_ant.pas

@@ -0,0 +1,18 @@
+unit implinline3_ant;
+
+{$mode objfpc}
+
+interface
+
+uses implinline3_bird;
+
+function Times123(w : word): word;
+
+implementation
+
+function Times123(w : word): word; inline;
+begin
+  Result := w*123;
+end;
+
+end.

+ 18 - 0
tests/tppu/implinline3/src1/implinline3_bird.pas

@@ -0,0 +1,18 @@
+unit implinline3_bird;
+
+{$mode objfpc}
+
+interface
+
+procedure Walk;
+
+implementation
+
+uses implinline3_ant;
+
+procedure Walk; inline;
+begin
+  writeln(Times123(2));
+end;
+
+end.

+ 18 - 0
tests/tppu/implinline3/src2/implinline3_ant.pas

@@ -0,0 +1,18 @@
+unit implinline3_ant;
+
+{$mode objfpc}
+
+interface
+
+uses implinline3_bird;
+
+function Times123(w : word): word;
+
+implementation
+
+function Times123(w : word): word; inline;
+begin
+  Result := 123 * w; // changed
+end;
+
+end.

+ 18 - 0
tests/tppu/implinline3/src2/implinline3_bird.pas

@@ -0,0 +1,18 @@
+unit implinline3_bird;
+
+{$mode objfpc}
+
+interface
+
+procedure Walk;
+
+implementation
+
+uses implinline3_ant;
+
+procedure Walk; inline;
+begin
+  writeln(Times123(2));
+end;
+
+end.

+ 63 - 4
tests/tppu/tcrecompile.pas

@@ -37,10 +37,15 @@ type
     procedure GetCompiler;
     procedure GetCompiler;
     procedure CheckCompiler;
     procedure CheckCompiler;
   published
   published
-    procedure TestTwoUnits;
-    procedure TestImplInline1;
-    procedure TestImplInline2;
-    procedure TestImplInline_Bug41291;
+    procedure TestTwoUnits; // 2 units
+    procedure TestChangeLeaf1; // prog+2 units, change leaf
+    procedure TestChangeInner1; // prog+2 units, change inner unit, keep leaf
+
+    // inline modifier in implementation (not in interface)
+    procedure TestImplInline1; // 2 units, cycle, impl inline
+    procedure TestImplInline2; // program + 2 units cycle, impl inline
+    procedure TestImplInline_Bug41291; // program plus 3 cycles
+    procedure TestImplInline3; // program + 2 units cycle, impl inline, implementation changed
   end;
   end;
 
 
 
 
@@ -222,6 +227,42 @@ begin
   CheckCompiled(['tppu_twounits_ant.pas']);
   CheckCompiled(['tppu_twounits_ant.pas']);
 end;
 end;
 
 
+procedure TTestRecompile.TestChangeLeaf1;
+begin
+  UnitPath:='changeleaf1;changeleaf1'+PathDelim+'src1';
+  OutDir:='changeleaf1'+PathDelim+'ppus';
+  MainSrc:='changeleaf1'+PathDelim+'changeleaf1_prg.pas';
+
+  Step:='First compile';
+  CleanOutputDir;
+  Compile;
+  CheckCompiled(['changeleaf1_prg.pas','changeleaf1_ant.pas','changeleaf1_bird.pas']);
+
+  Step:='Second compile';
+  UnitPath:='changeleaf1;changeleaf1'+PathDelim+'src2';
+  Compile;
+  // the main src is always compiled, bird changed, so all ant must be recompiled as well
+  CheckCompiled(['changeleaf1_prg.pas','changeleaf1_ant.pas','changeleaf1_bird.pas']);
+end;
+
+procedure TTestRecompile.TestChangeInner1;
+begin
+  UnitPath:='changeinner1;changeinner1'+PathDelim+'src1';
+  OutDir:='changeinner1'+PathDelim+'ppus';
+  MainSrc:='changeinner1'+PathDelim+'changeinner1_prg.pas';
+
+  Step:='First compile';
+  CleanOutputDir;
+  Compile;
+  CheckCompiled(['changeinner1_prg.pas','changeinner1_ant.pas','changeinner1_bird.pas']);
+
+  Step:='Second compile';
+  UnitPath:='changeinner1;changeinner1'+PathDelim+'src2';
+  Compile;
+  // the main src is always compiled, ant changed, bird is kept
+  CheckCompiled(['changeinner1_prg.pas','changeinner1_ant.pas']);
+end;
+
 procedure TTestRecompile.TestImplInline1;
 procedure TTestRecompile.TestImplInline1;
 // unit ant uses bird
 // unit ant uses bird
 // unit bird impl uses ant and has a function with inline modifier in implementation
 // unit bird impl uses ant and has a function with inline modifier in implementation
@@ -279,6 +320,24 @@ begin
   CheckCompiled(['bug41291_app.pas']);
   CheckCompiled(['bug41291_app.pas']);
 end;
 end;
 
 
+procedure TTestRecompile.TestImplInline3;
+begin
+  UnitPath:='implinline3;implinline3'+PathDelim+'src1';
+  OutDir:='implinline3'+PathDelim+'ppus';
+  MainSrc:='implinline3'+PathDelim+'implinline3_prg.pas';
+
+  Step:='First compile';
+  CleanOutputDir;
+  Compile;
+  CheckCompiled(['implinline3_prg.pas','implinline3_ant.pas','implinline3_bird.pas']);
+
+  Step:='Second compile';
+  UnitPath:='implinline3;implinline3'+PathDelim+'src2';
+  Compile;
+  // the main src is always compiled, and the ant impl changed, so bird is also compiled
+  CheckCompiled(['implinline3_prg.pas','implinline3_ant.pas','implinline3_bird.pas']);
+end;
+
 initialization
 initialization
   RegisterTests([TTestRecompile]);
   RegisterTests([TTestRecompile]);