blob: 32b91e315052406bf098ab679a6ce5355d277d67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
{ %VERSION=1.1 }
{$mode objfpc}
type
to1 = class
destructor destroy;override;
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;
inherited destroy;
end;
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:=2000;
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;
o2.destroy;
if i<>5000 then
halt(1);
writeln('ok');
end.
|