summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-12-26 12:21:05 +0000
committerpaul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-12-26 12:21:05 +0000
commit25bfa1ed48a8cc734f70954c3f2dd2ff7aad22a7 (patch)
tree398e9cee88997a518304cf5b2cea405229f88e48
parent52292082ad53f7d7257257c3db3d597d106f61ab (diff)
downloadfpc-25bfa1ed48a8cc734f70954c3f2dd2ff7aad22a7.tar.gz
tests: add Negative and Positive operators test
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16641 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--tests/test/terecs6.pp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test/terecs6.pp b/tests/test/terecs6.pp
index f0a5551612..5a7b8c9aa3 100644
--- a/tests/test/terecs6.pp
+++ b/tests/test/terecs6.pp
@@ -34,6 +34,8 @@ type
class operator BitwiseXor(a, b: TFoo): TFoo;
class operator Inc(a: TFoo): TFoo;
class operator Dec(a: TFoo): TFoo;
+ class operator Negative(a: TFoo): TFoo;
+ class operator Positive(a: TFoo): TFoo;
end;
class operator TFoo.Explicit(a: TFoo): Integer;
@@ -167,6 +169,17 @@ begin
Result.F := a.F - 1;
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
a, b: TFoo;
i: integer;
@@ -232,5 +245,11 @@ begin
halt(26);
if Integer(b) <> 2 then
halt(27);
+ b := -b;
+ if b.F <> -1 then
+ halt(28);
+ b := +b;
+ if b.F <> 0 then
+ halt(29);
WriteLn('ok');
end.