Browse Source

* more delphi/fpc procvar address tests

pierre 22 years ago
parent
commit
856d87c173
3 changed files with 86 additions and 4 deletions
  1. 17 4
      tests/tbs/tb0433.pp
  2. 32 0
      tests/tbs/tb0433a.pp
  3. 37 0
      tests/tbs/tb0433b.pp

+ 17 - 4
tests/tbs/tb0433.pp

@@ -1,7 +1,13 @@
-{$ifdef FPC}
-{$mode Delphi}
-{$endif}
-{$APPTYPE CONSOLE}
+{$ifdef fpc}
+{$mode tp}
+{$endif fpc}
+
+function times2(x : longint) : longint;
+
+begin
+  times2:=2*x;
+end;
+
 var
 var
  x:function(x:longint):longint;
  x:function(x:longint):longint;
  y:pointer absolute x;
  y:pointer absolute x;
@@ -21,4 +27,11 @@ begin
     writeln('Absolute Error');
     writeln('Absolute Error');
     halt(1);
     halt(1);
   end;
   end;
+ x:=times2;
+ if (y<>@times2) then
+  begin
+    writeln('Absolute Error');
+    halt(1);
+  end;
+
 end.
 end.

+ 32 - 0
tests/tbs/tb0433a.pp

@@ -0,0 +1,32 @@
+{$ifdef fpc}
+{$mode delphi}
+{$endif fpc}
+
+function times2(x : longint) : longint;
+
+begin
+  times2:=2*x;
+end;
+
+var
+ x:function(x:longint):longint;
+ y:pointer absolute x;
+ z,w,v:pointer;
+begin
+ x:=times2;
+ z:=@x;
+ w:=addr(x);
+ v:=@times2;
+ writeln(longint(y),' ',longint(z),' ',longint(w),' ',longint(v));
+ if (z<>w) or (z<>v) or (y<>z) then
+  begin
+    writeln('Addr Error');
+    halt(1);
+  end;
+ if (y<>@times2) then
+  begin
+    writeln('Absolute Error');
+    halt(1);
+  end;
+
+end.

+ 37 - 0
tests/tbs/tb0433b.pp

@@ -0,0 +1,37 @@
+{$ifdef fpc}
+{$mode fpc}
+{$endif fpc}
+
+function times2(x : longint) : longint;
+
+begin
+  times2:=2*x;
+end;
+
+var
+ x:function(x:longint):longint;
+ y:pointer absolute x;
+ z,w,v:pointer;
+begin
+ z:=@x;
+ w:=addr(x);
+ v:=@y;
+ writeln(longint(y),' ',longint(z),' ',longint(w),' ',longint(v));
+ if (z<>w) or (z<>v) then
+  begin
+    writeln('Addr Error');
+    halt(1);
+  end;
+ if (y<>nil) then
+  begin
+    writeln('Absolute Error');
+    halt(1);
+  end;
+ x:=@times2;
+ if (y<>pointer(@times2)) then
+  begin
+    writeln('Absolute Error');
+    halt(1);
+  end;
+
+end.