summaryrefslogtreecommitdiff
path: root/tests/test/tclass1.pp
blob: 3f4923f7aab157357581cd743d3d59e2cdd4c545 (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
{ %VERSION=1.1 }
{$mode objfpc}

type
   to1 = class
      constructor create;
      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;
   o2:=to2.create;
   if i<>5000 then
     halt(1);
   o1.destroy;
   writeln('ok');
end.