Browse Source

pastojs: proc references: fixed duplicate names

git-svn-id: trunk@38575 -
Mattias Gaertner 7 years ago
parent
commit
53aa36a0e4
2 changed files with 73 additions and 0 deletions
  1. 32 0
      packages/pastojs/tests/tcfiler.pas
  2. 41 0
      packages/pastojs/tests/tcprecompile.pas

+ 32 - 0
packages/pastojs/tests/tcfiler.pas

@@ -149,6 +149,7 @@ type
     procedure TestPC_Proc_Arg;
     procedure TestPC_Proc_Arg;
     procedure TestPC_Class;
     procedure TestPC_Class;
     procedure TestPC_ClassForward;
     procedure TestPC_ClassForward;
+    procedure TestPC_ClassConstructor;
     procedure TestPC_Initialization;
     procedure TestPC_Initialization;
     procedure TestPC_BoolSwitches;
     procedure TestPC_BoolSwitches;
 
 
@@ -1806,6 +1807,37 @@ begin
   WriteReadUnit;
   WriteReadUnit;
 end;
 end;
 
 
+procedure TTestPrecompile.TestPC_ClassConstructor;
+begin
+  StartUnit(false);
+  Add([
+  'interface',
+  'type',
+  '  TObject = class',
+  '    constructor Create; virtual;',
+  '  end;',
+  '  TBird = class',
+  '    constructor Create; override;',
+  '  end;',
+  'procedure DoIt;',
+  'implementation',
+  'constructor TObject.Create;',
+  'begin',
+  'end;',
+  'constructor TBird.Create;',
+  'begin',
+  '  inherited;',
+  'end;',
+  'procedure DoIt;',
+  'var b: TBird;',
+  'begin',
+  '  b:=TBird.Create;',
+  'end;',
+  'end.'
+  ]);
+  WriteReadUnit;
+end;
+
 procedure TTestPrecompile.TestPC_Initialization;
 procedure TTestPrecompile.TestPC_Initialization;
 begin
 begin
   StartUnit(false);
   StartUnit(false);

+ 41 - 0
packages/pastojs/tests/tcprecompile.pas

@@ -55,6 +55,7 @@ type
     procedure TestPCU_Overloads;
     procedure TestPCU_Overloads;
     procedure TestPCU_UnitCycle;
     procedure TestPCU_UnitCycle;
     procedure TestPCU_ClassForward;
     procedure TestPCU_ClassForward;
+    procedure TestPCU_ClassConstructor;
   end;
   end;
 
 
 function LinesToList(const Lines: array of string): TStringList;
 function LinesToList(const Lines: array of string): TStringList;
@@ -274,6 +275,46 @@ begin
   CheckPrecompile('test1.pas','src');
   CheckPrecompile('test1.pas','src');
 end;
 end;
 
 
+procedure TTestCLI_Precompile.TestPCU_ClassConstructor;
+begin
+  AddUnit('src/system.pp',[
+    'type integer = longint;',
+    'procedure Writeln; varargs;'],
+    ['procedure Writeln; begin end;']);
+  AddUnit('src/unit1.pp',[
+    'type',
+    '  TObject = class',
+    '    constructor Create;',
+    '  end;',
+    '  TBird = class',
+    '    constructor Create; reintroduce;',
+    '  end;',
+    '  TCow = class',
+    '    constructor Create; reintroduce;',
+    '  end;',
+    ''],[
+    'constructor TObject.Create; begin end;',
+    'constructor TBird.Create; begin end;',
+    'constructor TCow.Create; begin end;',
+    '']);
+  AddUnit('src/unit2.pp',[
+    'uses unit1;',
+    'procedure DoIt;',
+    ''],[
+    'procedure DoIt;',
+    'begin',
+    '  TBird.Create;',
+    '  TCow.Create;',
+    'end;',
+    '']);
+  AddFile('test1.pas',[
+    'uses unit2;',
+    'begin',
+    '  DoIt;',
+    'end.']);
+  CheckPrecompile('test1.pas','src');
+end;
+
 Initialization
 Initialization
   RegisterTests([TTestCLI_Precompile]);
   RegisterTests([TTestCLI_Precompile]);
 end.
 end.