From a78099a64f99cf52f4abf5d0cb249c5684cf1468 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 30 Mar 2003 21:00:19 +0000 Subject: [PATCH] * extended the tests with inherited call --- tests/test/tclass1.pp | 32 ++++++++++++++++++++++++++++++-- tests/test/tclass2.pp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tests/test/tclass1.pp b/tests/test/tclass1.pp index 7a9cdeff0d..afdba18cde 100644 --- a/tests/test/tclass1.pp +++ b/tests/test/tclass1.pp @@ -7,33 +7,61 @@ type procedure afterconstruction;override; end; + to2 = class(to1) + constructor create; + procedure afterconstruction;override; + end; + var i : longint; constructor to1.create; begin + writeln('to1.create'); inherited create; if i<>1000 then halt(1); i:=2000; end; + constructor to2.create; + + begin + writeln('to2.create'); + if i<>3000 then + halt(1); + i:=1000; + inherited create; + i:=4000; + end; + procedure to1.afterconstruction; begin + writeln('to1.afterconstruction'); if i<>2000 then halt(1); i:=3000; end; + procedure to2.afterconstruction; + + begin + writeln('to2.afterconstruction'); + if i<>4000 then + halt(1); + i:=5000; + end; + var o1 : to1; - + o2 : to2; begin i:=1000; o1:=to1.create; - if i<>3000 then + o2:=to2.create; + if i<>5000 then halt(1); o1.destroy; writeln('ok'); diff --git a/tests/test/tclass2.pp b/tests/test/tclass2.pp index e91c9cc584..ae22ef5fea 100644 --- a/tests/test/tclass2.pp +++ b/tests/test/tclass2.pp @@ -7,12 +7,18 @@ type procedure beforedestruction;override; end; + to2 = class(to1) + destructor destroy;override; + procedure beforedestruction;override; + end; + var i : longint; destructor to1.destroy; begin + writeln('to1.destroy'); if i<>2000 then halt(1); i:=3000; @@ -22,19 +28,42 @@ var procedure to1.beforedestruction; begin + writeln('to1.beforedestruction'); if i<>1000 then halt(1); i:=2000; end; + destructor to2.destroy; + + begin + writeln('to2.destroy'); + if i<>4000 then + halt(1); + i:=1000; + inherited destroy; + i:=5000; + end; + + procedure to2.beforedestruction; + + begin + writeln('to2.beforedestruction'); + if i<>3000 then + halt(1); + i:=4000; + end; + var o1 : to1; - + o2 : to2; begin o1:=to1.create; + o2:=to2.create; i:=1000; o1.destroy; - if i<>3000 then + o2.destroy; + if i<>5000 then halt(1); writeln('ok'); end.