Test suite results for test file test/cg/tclatype.pp

Test run data :

Free Pascal Compiler Test Suite Results

View Test suite results

Please specify search criteria:
File:
Operating system:
Processor:
Version
Date
Submitter
Machine
Comment
Limit
Cond
Category
Only failed tests
Hide skipped tests
List all tests

Test file "test/cg/tclatype.pp" information:

t_id 168
t_adddate 2003/10/03
t_result 0
t_knownrunerror 0

Detailed test run results:

Record count: 50

Total = 50

OK=50 Percentage= 100.00

Result type Cat. Count Percentage First date Last Date
Successfully run 50 100.0 2024/05/21 05:08:00 158 2024/05/21 07:52:00 0
i386 4 8.0 2024/05/21 06:26:00 59 2024/05/21 07:25:00 42
m68k 3 6.0 2024/05/21 06:59:00 58 2024/05/21 07:39:00 58
sparc 4 8.0 2024/05/21 06:46:00 68 2024/05/21 07:52:00 0
powerpc 9 18.0 2024/05/21 06:28:00 52 2024/05/21 07:24:00 181
arm 3 6.0 2024/05/21 06:43:00 210 2024/05/21 07:18:00 40
x86_64 2 4.0 2024/05/21 06:12:00 30 2024/05/21 06:21:00 29
powerpc64 5 10.0 2024/05/21 05:53:00 132 2024/05/21 07:32:00 77
mips 3 6.0 2024/05/21 07:08:00 154 2024/05/21 07:46:00 0
mipsel 3 6.0 2024/05/21 06:07:00 151 2024/05/21 07:17:00 228
aarch64 8 16.0 2024/05/21 06:35:00 23 2024/05/21 07:39:00 37
sparc64 3 6.0 2024/05/21 05:08:00 158 2024/05/21 07:17:00 165
riscv64 1 2.0 2024/05/21 07:46:00 0 2024/05/21 07:46:00 0
loongarch64 2 4.0 2024/05/21 07:01:00 34 2024/05/21 07:33:00 38
linux 43 86.0 2024/05/21 05:08:00 158 2024/05/21 07:52:00 0
go32v2 1 2.0 2024/05/21 06:26:00 59 2024/05/21 06:26:00 59
solaris 2 4.0 2024/05/21 06:12:00 30 2024/05/21 06:21:00 29
darwin 4 8.0 2024/05/21 06:35:00 23 2024/05/21 07:04:00 38
3.3.1 29 58.0 2024/05/21 05:08:00 158 2024/05/21 07:52:00 0
3.2.3 21 42.0 2024/05/21 06:07:00 151 2024/05/21 07:50:00 0

Source:


{$mode objfpc}

type
   tbaseclass = class
     x : longint;
     function get_type : pointer;
     function get_type2 : pointer;virtual;
     procedure check_type;
     class procedure virtual_class_method;virtual;
   end;

   tderivedclass = class(tbaseclass)
     y : longint;
     function get_type2 : pointer;override;
     class procedure virtual_class_method;override;
   end;

const
  tbasecalled : boolean = false;
  tderivedcalled : boolean = false;
  has_error : boolean = false;
  expected_size_for_tbaseclass = sizeof(pointer) + sizeof(longint);
  expected_size_for_tderivedclass = sizeof(pointer) + 2*sizeof(longint);

var
  basesize : longint;
  derivedsize : longint;

function tbaseclass.get_type : pointer;
begin
  get_type:=typeof(self);
end;

function tbaseclass.get_type2 : pointer;
begin
  get_type2:=typeof(self);
end;

procedure tbaseclass.check_type;
begin
  if typeof(self)<>get_type then
    begin
      Writeln('Compiler creates garbage');
      has_error:=true;
    end;
  if typeof(self)<>get_type2 then
    begin
      Writeln('Compiler creates garbage');
      has_error:=true;
    end;
  if get_type<>get_type2 then
    begin
      Writeln('get_type and get_type2 return different pointers');
      has_error:=true;
    end;
end;

procedure tbaseclass.virtual_class_method;
begin
  Writeln('Calling tbase class class method');
  tbasecalled:=true;
  if sizeof(self)<>basesize then
    begin
      has_error:=true;
      Writeln('Error with sizeof');
    end;
end;

function tderivedclass.get_type2 : pointer;
begin
  get_type2:=typeof(self);
end;

procedure tderivedclass.virtual_class_method;
begin
  Writeln('Calling tderived class class method');
  tderivedcalled:=true;
  if sizeof(self)<>derivedsize then
    begin
      has_error:=true;
      Writeln('Error with sizeof');
    end;
end;

procedure reset_booleans;
begin
  tbasecalled:=false;
  tderivedcalled:=false;
end;

var
  c1,cb : tbaseclass;
  cd : tderivedclass;
  cc : class of tbaseclass;
  pb,pd : pointer;

begin
 cb:=tbaseclass.create;
 cd:=tderivedclass.create;
 c1:=tbaseclass.create;

 basesize:=sizeof(cb);
 Writeln('Sizeof(cb)=',basesize);
 if basesize<>sizeof(pointer) then
   Writeln('not the expected size : ',sizeof(pointer));

 derivedsize:=sizeof(cd);
 Writeln('Sizeof(ct)=',derivedsize);
 if derivedsize<>sizeof(pointer) then
   Writeln('not the expected size : ',sizeof(pointer));

 cb.check_type;
 cd.check_type;

 c1.destroy;

 c1:=tderivedclass.create;

 c1.virtual_class_method;
 if not tderivedcalled then
   has_error:=true;
 reset_booleans;

 c1.destroy;

 cc:=tbaseclass;

 cc.virtual_class_method;
 if not tbasecalled then
   has_error:=true;
 reset_booleans;

 cc:=tderivedclass;


 cc.virtual_class_method;
 if not tderivedcalled then
   has_error:=true;
 reset_booleans;

 if has_error then
   begin
     Writeln('Error with class methods');
     halt(1);
   end;

end.

Link to SVN view of test/cg/tclatype.pp source.