summaryrefslogtreecommitdiff
path: root/tests/test/tmacpas3.pp
blob: 476fc68848bd5002741830a964bd28696fa466f0 (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
{$mode macpas}

{Test of anonymous procedure parameters}

function AA1 (i: Integer; function BB (a: Integer): Integer ): Integer;
begin
  AA1:= BB(i);
end;

function CC1 (a: Integer): Integer;
begin
  Writeln('Inside CC1, param is ', a);
  CC1:= a+a;
end;

var
  res: Integer;

procedure AA2 (i: Integer; procedure BB (a: Integer));
begin
  BB(i);
end;

procedure CC2 (a: Integer);
begin
  Writeln('Inside CC2, param is ', a);
  res:= a+a;
end;

begin
  res:= 0;
  res:= AA1(42, CC1);
  if res <> 84 then
    Halt(1);

  AA2(27, CC2);
  if res <> 54 then
    Halt(1);
end.