mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-07 20:46:06 +02:00
* global properties
This commit is contained in:
parent
dce7bf35f9
commit
a42f9109c0
39
tests/test/tprop1.pp
Normal file
39
tests/test/tprop1.pp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{$mode fpc}
|
||||||
|
var
|
||||||
|
FErrno : longint;
|
||||||
|
function GetROVar:longint;
|
||||||
|
begin
|
||||||
|
GetROVar:=3;
|
||||||
|
end;
|
||||||
|
function GetErrno:longint;
|
||||||
|
begin
|
||||||
|
GetErrno:=FErrno;
|
||||||
|
end;
|
||||||
|
procedure SetErrno(e:longint);
|
||||||
|
begin
|
||||||
|
FErrno:=e;
|
||||||
|
end;
|
||||||
|
|
||||||
|
property
|
||||||
|
Errno:longint read GetErrno write SetErrno;
|
||||||
|
ROVar:longint read GetROVar;
|
||||||
|
|
||||||
|
begin
|
||||||
|
FErrno:=1;
|
||||||
|
if Errno<>1 then
|
||||||
|
begin
|
||||||
|
writeln('Error 1');
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
Errno:=2;
|
||||||
|
if Errno<>2 then
|
||||||
|
begin
|
||||||
|
writeln('Error 2');
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
if ROVar<>3 then
|
||||||
|
begin
|
||||||
|
writeln('Error 3');
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
end.
|
14
tests/test/tprop2.pp
Normal file
14
tests/test/tprop2.pp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ %fail }
|
||||||
|
{$mode fpc}
|
||||||
|
|
||||||
|
function GetROVar:longint;
|
||||||
|
begin
|
||||||
|
GetROVar:=3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
property
|
||||||
|
ROVar:longint read GetROVar;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ROVar:=1;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user