summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw4007.pp
blob: 7d4031c2948e4ff833b636da210ba35aee4415e8 (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
{ Source provided for Free Pascal Bug Report 4007 }
{ Submitted by "Torsten Kildal" on  2005-05-23 }
{ e-mail: kildal@gmx.de }
PROGRAM H;
{$IFDEF FPC} {$MODE TP} {$ENDIF}

VAR
  Handler: function: boolean;

  function AHandler: boolean; far;
  begin
    AHandler:=true;
  end;

begin
  Handler:= AHandler;

  {here FPC differs from BP ->BUG}
  if Handler then writeln('1');
  {BP7 : '1'}
  {1010: '1'}
  {19x : Boolean expression expected, but got "<procedure variable type of function:Boolean;Register>"}
  {200 : Boolean expression expected, but got "<procedure variable type of function:Boolean;Register>"}

  {the same with "=true" shows no difference -> conflict to '1'}
  if Handler=true then writeln('2');
  {BP7 : '2'}
  {1010: '2'}
  {19x : '2'}
  {200 : '2'}

  {here FPC differs from BP again -> BUG}
  if Handler() then writeln('3');
  {BP7 : THEN expected}
  {1010: '3'}
  {19x : '3'}
  {200 : '3'}

{$ifdef nok}
  {this both BP and FPC don't like -> ok}
  if Handler=NIL then writeln('4');
  {BP7 : Type Mismatch}
  {1010: Operator is not overloaded}
  {19x : Incompatible types: got "Boolean" expected "LongInt"}
  {200 : Incompatible types: got "Boolean" expected "LongInt"}
{$endif nok}

  {the rest is accepted by both BP and FPC -> ok}
  if @Handler<>NIL     then writeln('5');
  if assigned(Handler) then writeln('6');

end.

(*
  "BP7"  = Borland Pascal 7.0       -> 1,2,    5,6
  "1010" = FPC 1.0.10               -> 1,2,3,  5,6
  "19x"  = FPC 1.9.4 / 1.9.6        ->   2,3,  5,6
  "200"  = FPC 2.0.0                ->   2,3,  5,6
*)