mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 18:47:52 +02:00
* more delphi/fpc procvar address tests
This commit is contained in:
parent
a59fbd968d
commit
856d87c173
@ -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
|
||||
x:function(x:longint):longint;
|
||||
y:pointer absolute x;
|
||||
@ -21,4 +27,11 @@ begin
|
||||
writeln('Absolute Error');
|
||||
halt(1);
|
||||
end;
|
||||
x:=times2;
|
||||
if (y<>@times2) then
|
||||
begin
|
||||
writeln('Absolute Error');
|
||||
halt(1);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
32
tests/tbs/tb0433a.pp
Normal file
32
tests/tbs/tb0433a.pp
Normal file
@ -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
tests/tbs/tb0433b.pp
Normal file
37
tests/tbs/tb0433b.pp
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user