mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 08:59:05 +02:00
tests: add Negative and Positive operators test
git-svn-id: trunk@16641 -
This commit is contained in:
parent
ee6fe6c4f5
commit
fb2c465f22
@ -34,6 +34,8 @@ type
|
|||||||
class operator BitwiseXor(a, b: TFoo): TFoo;
|
class operator BitwiseXor(a, b: TFoo): TFoo;
|
||||||
class operator Inc(a: TFoo): TFoo;
|
class operator Inc(a: TFoo): TFoo;
|
||||||
class operator Dec(a: TFoo): TFoo;
|
class operator Dec(a: TFoo): TFoo;
|
||||||
|
class operator Negative(a: TFoo): TFoo;
|
||||||
|
class operator Positive(a: TFoo): TFoo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class operator TFoo.Explicit(a: TFoo): Integer;
|
class operator TFoo.Explicit(a: TFoo): Integer;
|
||||||
@ -167,6 +169,17 @@ begin
|
|||||||
Result.F := a.F - 1;
|
Result.F := a.F - 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.Negative(a: TFoo): TFoo;
|
||||||
|
begin
|
||||||
|
Result.F := -a.F;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.Positive(a: TFoo): TFoo;
|
||||||
|
begin
|
||||||
|
// to check that operator is called change the result value
|
||||||
|
Result.F := a.F+1;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
a, b: TFoo;
|
a, b: TFoo;
|
||||||
i: integer;
|
i: integer;
|
||||||
@ -232,5 +245,11 @@ begin
|
|||||||
halt(26);
|
halt(26);
|
||||||
if Integer(b) <> 2 then
|
if Integer(b) <> 2 then
|
||||||
halt(27);
|
halt(27);
|
||||||
|
b := -b;
|
||||||
|
if b.F <> -1 then
|
||||||
|
halt(28);
|
||||||
|
b := +b;
|
||||||
|
if b.F <> 0 then
|
||||||
|
halt(29);
|
||||||
WriteLn('ok');
|
WriteLn('ok');
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user