mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 23:47:52 +02:00
* testss for class overload and virtual
This commit is contained in:
parent
a059a1671d
commit
8bbd570d12
32
tests/tbf/tb0114.pp
Normal file
32
tests/tbf/tb0114.pp
Normal file
@ -0,0 +1,32 @@
|
||||
{ %FAIL }
|
||||
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
type
|
||||
tobj = class
|
||||
procedure proc1 (a: integer);virtual;
|
||||
end;
|
||||
|
||||
tobj1 = class (tobj)
|
||||
procedure proc1 (a: char);
|
||||
end;
|
||||
|
||||
tobj2 = class (tobj1)
|
||||
{ this will try to override tobj1.proc1 which is not
|
||||
allowed and therefor needs an error }
|
||||
procedure proc1 (a: integer);override;
|
||||
end;
|
||||
|
||||
procedure tobj.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
17
tests/tbf/tb0115.pp
Normal file
17
tests/tbf/tb0115.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{ %FAIL }
|
||||
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
uses ub0115;
|
||||
type
|
||||
tobj2 = class (tobj)
|
||||
{ this will try to override tobj.proc1 which is private
|
||||
and can not be seen. This needs an error }
|
||||
procedure proc1 (a: integer);override;
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
32
tests/tbf/tb0116.pp
Normal file
32
tests/tbf/tb0116.pp
Normal file
@ -0,0 +1,32 @@
|
||||
{ %FAIL }
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
type
|
||||
tobj1 = class
|
||||
procedure proc1 (a: char);
|
||||
end;
|
||||
|
||||
tobj2 = class (tobj1)
|
||||
procedure proc1 (a: integer);
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
write('tobj1.proc1(a:char) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj2.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
var
|
||||
obj1: tobj1;
|
||||
obj2: tobj2;
|
||||
begin
|
||||
obj1:=tobj1.create;
|
||||
obj2:=tobj2.create;
|
||||
|
||||
obj2.proc1 ('a');
|
||||
end.
|
17
tests/tbf/ub0115.pp
Normal file
17
tests/tbf/ub0115.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
unit ub0115;
|
||||
interface
|
||||
|
||||
type
|
||||
tobj = class
|
||||
private
|
||||
procedure proc1 (a: integer);overload; virtual;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure tobj.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
end.
|
15
tests/tbs/tb0386.pp
Normal file
15
tests/tbs/tb0386.pp
Normal file
@ -0,0 +1,15 @@
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
uses ub0386;
|
||||
type
|
||||
tobj2 = class (tobj1)
|
||||
{ this will try to override tobj.proc1, it should not
|
||||
see tobj1.proc1 }
|
||||
procedure proc1 (a: integer);override;
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
33
tests/tbs/tb0387.pp
Normal file
33
tests/tbs/tb0387.pp
Normal file
@ -0,0 +1,33 @@
|
||||
{ %VERSION=1.1 }
|
||||
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
type
|
||||
tobj1 = class
|
||||
procedure proc1 (a: char);
|
||||
end;
|
||||
|
||||
tobj2 = class (tobj1)
|
||||
procedure proc1 (a: integer);overload;
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
write('tobj1.proc1(a:char) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj2.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
var
|
||||
obj1: tobj1;
|
||||
obj2: tobj2;
|
||||
begin
|
||||
obj1:=tobj1.create;
|
||||
obj2:=tobj2.create;
|
||||
|
||||
obj2.proc1 ('a');
|
||||
end.
|
51
tests/tbs/tb0388.pp
Normal file
51
tests/tbs/tb0388.pp
Normal file
@ -0,0 +1,51 @@
|
||||
{ %VERSION=1.1 }
|
||||
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
type
|
||||
tobj = class
|
||||
procedure proc1 (a: integer);virtual;
|
||||
end;
|
||||
|
||||
tobj1 = class(tobj)
|
||||
procedure proc1 (a: integer);overload;override;
|
||||
procedure proc1 (a: char);overload;
|
||||
end;
|
||||
|
||||
tobj2 = class (tobj1)
|
||||
procedure proc1 (a: integer);override;
|
||||
end;
|
||||
|
||||
procedure tobj.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj1.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
write('tobj1.proc1(a:char) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj2.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
var
|
||||
obj1: tobj1;
|
||||
obj2: tobj2;
|
||||
begin
|
||||
obj1:=tobj1.create;
|
||||
obj2:=tobj2.create;
|
||||
|
||||
obj2.proc1 (100);
|
||||
obj2.proc1 ('a');
|
||||
end.
|
59
tests/tbs/tb0389.pp
Normal file
59
tests/tbs/tb0389.pp
Normal file
@ -0,0 +1,59 @@
|
||||
{ %VERSION=1.1 }
|
||||
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
type
|
||||
tobj = class
|
||||
procedure proc1 (a: integer);overload;virtual;
|
||||
procedure proc1 (a: extended);overload;
|
||||
end;
|
||||
|
||||
tobj1 = class(tobj)
|
||||
procedure proc1 (a: integer);overload;override;
|
||||
procedure proc1 (a: char);overload;
|
||||
end;
|
||||
|
||||
tobj2 = class (tobj1)
|
||||
procedure proc1 (a: integer);override;
|
||||
end;
|
||||
|
||||
procedure tobj.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj.proc1 (a: extended);
|
||||
begin
|
||||
write('tobj.proc1(a:extended) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj1.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
write('tobj1.proc1(a:char) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
procedure tobj2.proc1 (a: integer);
|
||||
begin
|
||||
write('tobj2.proc1(a:integer) called: ');
|
||||
writeln (a);
|
||||
end;
|
||||
|
||||
var
|
||||
obj1: tobj1;
|
||||
obj2: tobj2;
|
||||
begin
|
||||
obj1:=tobj1.create;
|
||||
obj2:=tobj2.create;
|
||||
|
||||
obj2.proc1 (100);
|
||||
obj2.proc1 ('a');
|
||||
obj2.proc1 (123.456);
|
||||
end.
|
26
tests/tbs/ub0386.pp
Normal file
26
tests/tbs/ub0386.pp
Normal file
@ -0,0 +1,26 @@
|
||||
{$ifdef fpc}{$mode objfpc}{$endif}
|
||||
unit ub0386;
|
||||
interface
|
||||
|
||||
type
|
||||
tobj = class
|
||||
procedure proc1 (a: integer);overload; virtual;
|
||||
end;
|
||||
|
||||
tobj1 = class(tobj)
|
||||
{ this proc1 definition should not been seen by tobj2 }
|
||||
private
|
||||
procedure proc1 (a: char);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure tobj.proc1 (a: integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure tobj1.proc1 (a: char);
|
||||
begin
|
||||
end;
|
||||
|
||||
end.
|
Loading…
Reference in New Issue
Block a user