From 8bbd570d128868ea6f3240ba4303bb6e43307f16 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 3 Nov 2001 20:11:00 +0000 Subject: [PATCH] * testss for class overload and virtual --- tests/tbf/tb0114.pp | 32 ++++++++++++++++++++++++ tests/tbf/tb0115.pp | 17 +++++++++++++ tests/tbf/tb0116.pp | 32 ++++++++++++++++++++++++ tests/tbf/ub0115.pp | 17 +++++++++++++ tests/tbs/tb0386.pp | 15 ++++++++++++ tests/tbs/tb0387.pp | 33 +++++++++++++++++++++++++ tests/tbs/tb0388.pp | 51 +++++++++++++++++++++++++++++++++++++++ tests/tbs/tb0389.pp | 59 +++++++++++++++++++++++++++++++++++++++++++++ tests/tbs/ub0386.pp | 26 ++++++++++++++++++++ 9 files changed, 282 insertions(+) create mode 100644 tests/tbf/tb0114.pp create mode 100644 tests/tbf/tb0115.pp create mode 100644 tests/tbf/tb0116.pp create mode 100644 tests/tbf/ub0115.pp create mode 100644 tests/tbs/tb0386.pp create mode 100644 tests/tbs/tb0387.pp create mode 100644 tests/tbs/tb0388.pp create mode 100644 tests/tbs/tb0389.pp create mode 100644 tests/tbs/ub0386.pp diff --git a/tests/tbf/tb0114.pp b/tests/tbf/tb0114.pp new file mode 100644 index 0000000000..1cbf7a46e4 --- /dev/null +++ b/tests/tbf/tb0114.pp @@ -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. diff --git a/tests/tbf/tb0115.pp b/tests/tbf/tb0115.pp new file mode 100644 index 0000000000..85a4252bdb --- /dev/null +++ b/tests/tbf/tb0115.pp @@ -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. diff --git a/tests/tbf/tb0116.pp b/tests/tbf/tb0116.pp new file mode 100644 index 0000000000..fc863c77c7 --- /dev/null +++ b/tests/tbf/tb0116.pp @@ -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. diff --git a/tests/tbf/ub0115.pp b/tests/tbf/ub0115.pp new file mode 100644 index 0000000000..930fe195df --- /dev/null +++ b/tests/tbf/ub0115.pp @@ -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. diff --git a/tests/tbs/tb0386.pp b/tests/tbs/tb0386.pp new file mode 100644 index 0000000000..82fa56cee0 --- /dev/null +++ b/tests/tbs/tb0386.pp @@ -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. diff --git a/tests/tbs/tb0387.pp b/tests/tbs/tb0387.pp new file mode 100644 index 0000000000..2f9191a650 --- /dev/null +++ b/tests/tbs/tb0387.pp @@ -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. diff --git a/tests/tbs/tb0388.pp b/tests/tbs/tb0388.pp new file mode 100644 index 0000000000..225eb91d31 --- /dev/null +++ b/tests/tbs/tb0388.pp @@ -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. diff --git a/tests/tbs/tb0389.pp b/tests/tbs/tb0389.pp new file mode 100644 index 0000000000..d457cde4c9 --- /dev/null +++ b/tests/tbs/tb0389.pp @@ -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. diff --git a/tests/tbs/ub0386.pp b/tests/tbs/ub0386.pp new file mode 100644 index 0000000000..1dc9f04d82 --- /dev/null +++ b/tests/tbs/ub0386.pp @@ -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.