mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 12:39:09 +02:00
tests: add also test for +,-,or,xor,and operators
git-svn-id: trunk@16625 -
This commit is contained in:
parent
b811f1be15
commit
714c4164ad
@ -1,4 +1,4 @@
|
|||||||
program terecs6;
|
program Project1;
|
||||||
|
|
||||||
{$mode delphi}
|
{$mode delphi}
|
||||||
{$apptype console}
|
{$apptype console}
|
||||||
@ -15,12 +15,23 @@ type
|
|||||||
class operator GreaterThanOrEqual(a, b: TFoo): Boolean;
|
class operator GreaterThanOrEqual(a, b: TFoo): Boolean;
|
||||||
class operator LessThan(a, b: TFoo): Boolean;
|
class operator LessThan(a, b: TFoo): Boolean;
|
||||||
class operator LessThanOrEqual(a, b: TFoo): Boolean;
|
class operator LessThanOrEqual(a, b: TFoo): Boolean;
|
||||||
|
class operator Add(a, b: TFoo): Integer;
|
||||||
|
class operator Subtract(a, b: TFoo): Integer;
|
||||||
class operator Multiply(a, b: TFoo): Integer;
|
class operator Multiply(a, b: TFoo): Integer;
|
||||||
class operator Divide(a, b: TFoo): Integer;
|
class operator Divide(a, b: TFoo): Integer;
|
||||||
class operator IntDivide(a, b: TFoo): Integer;
|
class operator IntDivide(a, b: TFoo): Integer;
|
||||||
class operator Modulus(a, b: TFoo): Integer;
|
class operator Modulus(a, b: TFoo): Integer;
|
||||||
class operator LeftShift(a, b: TFoo): Integer;
|
class operator LeftShift(a, b: TFoo): Integer;
|
||||||
class operator RightShift(a, b: TFoo): Integer;
|
class operator RightShift(a, b: TFoo): Integer;
|
||||||
|
class operator LogicalOr(a, b: TFoo): Boolean;
|
||||||
|
class operator LogicalAnd(a, b: TFoo): Boolean;
|
||||||
|
class operator LogicalXor(a, b: TFoo): Boolean;
|
||||||
|
// class operator LogicalNot(a: TFoo): TFoo;
|
||||||
|
// class operator BitwiseOr(a, b: TFoo): TFoo;
|
||||||
|
// class operator BitwiseAnd(a, b: TFoo): TFoo;
|
||||||
|
// class operator BitwiseXor(a, b: TFoo): TFoo;
|
||||||
|
// class operator Inc(a: TFoo): TFoo;
|
||||||
|
// class operator Dec(a: TFoo): TFoo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class operator TFoo.Equal(a, b: TFoo): Boolean;
|
class operator TFoo.Equal(a, b: TFoo): Boolean;
|
||||||
@ -58,6 +69,16 @@ begin
|
|||||||
Result := a.F <= b.F;
|
Result := a.F <= b.F;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.Add(a, b: TFoo): Integer;
|
||||||
|
begin
|
||||||
|
Result := a.F + b.F;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.Subtract(a, b: TFoo): Integer;
|
||||||
|
begin
|
||||||
|
Result := a.F - b.F;
|
||||||
|
end;
|
||||||
|
|
||||||
class operator TFoo.Multiply(a, b: TFoo): Integer;
|
class operator TFoo.Multiply(a, b: TFoo): Integer;
|
||||||
begin
|
begin
|
||||||
Result := a.F * b.F;
|
Result := a.F * b.F;
|
||||||
@ -88,6 +109,21 @@ begin
|
|||||||
Result := a.F shr b.F;
|
Result := a.F shr b.F;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.LogicalOr(a, b: TFoo): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (a.F or b.F) <> 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.LogicalAnd(a, b: TFoo): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (a.F and b.F) <> 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class operator TFoo.LogicalXor(a, b: TFoo): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (a.F xor b.F) <> 0;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
a, b: TFoo;
|
a, b: TFoo;
|
||||||
begin
|
begin
|
||||||
@ -121,5 +157,15 @@ begin
|
|||||||
halt(13);
|
halt(13);
|
||||||
if b shr a <> 1 then
|
if b shr a <> 1 then
|
||||||
halt(14);
|
halt(14);
|
||||||
|
if a + b <> 3 then
|
||||||
|
halt(15);
|
||||||
|
if a - b <> -1 then
|
||||||
|
halt(16);
|
||||||
|
if not (a or b) then
|
||||||
|
halt(17);
|
||||||
|
if a and b then
|
||||||
|
halt(18);
|
||||||
|
if not (a xor b) then
|
||||||
|
halt(19);
|
||||||
WriteLn('ok');
|
WriteLn('ok');
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user