fpc/tests/test/tgeneric93.pp
svenbarth d49b4043ab Implement DECLARED() for generic symbols. This fixes Mantis . The syntax is SomeGenericType<> for a generic with only one type parameter and SomeGeneric<,[,]*> for a generic with more than one type parameter. Spaces between the commas or brackets are allowed.
scanner.pas, parse_compiler_expr.read_factor:
  + allow "<>" after "declared" (handle "<>" operator specially)
  + count "," to get correct amount of type parameters
  + check together with the count string for symbols 
  + correctly handle dummy symbols

+ added tests

git-svn-id: trunk@23544 -
2013-01-30 16:10:15 +00:00

110 lines
1.8 KiB
ObjectPascal

program tgeneric93;
uses
ugeneric93a,
ugeneric93b;
const
// should be False
{$if declared(NotDeclared<>)}
TestNotDeclared = True;
{$else}
TestNotDeclared = False;
{$endif}
// should be False
{$if declared(TTestDelphi)}
TestTTestDelphi = True;
{$else}
TestTTestDelphi = False;
{$endif}
// should be True
{$if declared(TTestDelphi<>)}
TestTTestDelphi1 = True;
{$else}
TestTTestDelphi1 = False;
{$endif}
// should be False
{$if declared(TTestDelphi<,>)}
TestTTestDelphi2 = True;
{$else}
TestTTestDelphi2 = False;
{$endif}
// should be True
{$if declared(TTestDelphi<,,>)}
TestTTestDelphi3 = True;
{$else}
TestTTestDelphi3 = False;
{$endif}
// should be True
{$if declared(TTest2Delphi)}
TestTTest2Delphi = True;
{$else}
TestTTest2Delphi = False;
{$endif}
// should be False
{$if declared(TTest2Delphi<>)}
TestTTest2Delphi1 = True;
{$else}
TestTTest2Delphi1 = False;
{$endif}
// should be True
{$if declared(TTest2Delphi<,>)}
TestTTest2Delphi2 = True;
{$else}
TestTTest2Delphi2 = False;
{$endif}
// should be False
{$if declared(TTestFPC)}
TestTTestFPC = True;
{$else}
TestTTestFPC = False;
{$endif}
// should be False
{$if declared(TTestFPC<>)}
TestTTestFPC1 = True;
{$else}
TestTTestFPC1 = False;
{$endif}
// should be True
{$if declared(TTestFPC<,>)}
TestTTestFPC2 = True;
{$else}
TestTTestFPC2 = False;
{$endif}
begin
if TestNotDeclared then
Halt(1);
if TestTTestDelphi then
Halt(2);
if not TestTTestDelphi1 then
Halt(3);
if TestTTestDelphi2 then
Halt(4);
if not TestTTestDelphi3 then
Halt(5);
if not TestTTest2Delphi then
Halt(6);
if TestTTest2Delphi1 then
Halt(7);
if not TestTTest2Delphi2 then
Halt(8);
if TestTTestFPC then
Halt(9);
if TestTTestFPC1 then
Halt(10);
if not TestTTestFPC2 then
Halt(11);
Writeln('OK');
end.