Browse Source

* fixed sizeof() results

peter 22 years ago
parent
commit
aac2357acf
1 changed files with 13 additions and 12 deletions
  1. 13 12
      tests/test/cg/tclasize.pp

+ 13 - 12
tests/test/cg/tclasize.pp

@@ -1,6 +1,4 @@
-
-
-{$mode objfpc}
+{$ifdef fpc}{$mode objfpc}{$else}{$J+}{$endif}
 
 
 type
 type
    tbaseclass = class
    tbaseclass = class
@@ -27,7 +25,7 @@ var
   basesize : longint;
   basesize : longint;
   derivedsize : longint;
   derivedsize : longint;
 
 
-procedure tbaseclass.virtual_class_method;
+class procedure tbaseclass.virtual_class_method;
 
 
 begin
 begin
   Writeln('Calling tbase class class method');
   Writeln('Calling tbase class class method');
@@ -39,7 +37,7 @@ begin
     end;
     end;
 end;
 end;
 
 
-function tbaseclass.getsize : longint;
+class function tbaseclass.getsize : longint;
 begin
 begin
   getsize:=sizeof(self);
   getsize:=sizeof(self);
 end;
 end;
@@ -63,7 +61,7 @@ begin
     end;
     end;
 end;
 end;
 
 
-procedure tderivedclass.virtual_class_method;
+class procedure tderivedclass.virtual_class_method;
 
 
 begin
 begin
   Writeln('Calling tderived class class method');
   Writeln('Calling tderived class class method');
@@ -81,10 +79,13 @@ begin
   tderivedcalled:=false;
   tderivedcalled:=false;
 end;
 end;
 
 
+type
+  tcl = class of tbaseclass;
+
 var
 var
   c1,cb : tbaseclass;
   c1,cb : tbaseclass;
   cd : tderivedclass;
   cd : tderivedclass;
-  cc : class of tbaseclass;
+  cc : tcl;
 
 
 begin
 begin
  cb:=tbaseclass.create;
  cb:=tbaseclass.create;
@@ -93,8 +94,8 @@ begin
 
 
  basesize:=sizeof(cb);
  basesize:=sizeof(cb);
  Writeln('Sizeof(cb)=',basesize);
  Writeln('Sizeof(cb)=',basesize);
- if basesize<>expected_size_for_tbaseclass then
-   Writeln('not the expected size : ',expected_size_for_tbaseclass);
+ if basesize<>sizeof(pointer) then
+   Writeln('not the expected size : ',sizeof(pointer));
  Writeln('cb.InstanceSize=',Cb.InstanceSize);
  Writeln('cb.InstanceSize=',Cb.InstanceSize);
  if cb.InstanceSize<>expected_size_for_tbaseclass then
  if cb.InstanceSize<>expected_size_for_tbaseclass then
    Writeln('not the expected size : ',expected_size_for_tbaseclass);
    Writeln('not the expected size : ',expected_size_for_tbaseclass);
@@ -104,8 +105,8 @@ begin
 
 
  derivedsize:=sizeof(cd);
  derivedsize:=sizeof(cd);
  Writeln('Sizeof(ct)=',derivedsize);
  Writeln('Sizeof(ct)=',derivedsize);
- if derivedsize<>expected_size_for_tderivedclass then
-   Writeln('not the expected size : ',expected_size_for_tderivedclass);
+ if derivedsize<>sizeof(pointer) then
+   Writeln('not the expected size : ',sizeof(pointer));
 
 
  cb.check_size;
  cb.check_size;
  cd.check_size;
  cd.check_size;
@@ -180,7 +181,7 @@ begin
    has_error:=true;
    has_error:=true;
  reset_booleans;
  reset_booleans;
 
 
- Writeln('Szeof(cc)=',sizeof(cc));
+ Writeln('Sizeof(cc)=',sizeof(cc));
 
 
  if has_error then
  if has_error then
    begin
    begin