mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-30 17:46:06 +02:00
+ generics context sensitivity test
git-svn-id: trunk@7023 -
This commit is contained in:
parent
ed8e6b71e3
commit
245ce6f9a8
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -6768,6 +6768,7 @@ tests/test/tgeneric10.pp svneol=native#text/plain
|
|||||||
tests/test/tgeneric11.pp svneol=native#text/plain
|
tests/test/tgeneric11.pp svneol=native#text/plain
|
||||||
tests/test/tgeneric12.pp svneol=native#text/plain
|
tests/test/tgeneric12.pp svneol=native#text/plain
|
||||||
tests/test/tgeneric13.pp svneol=native#text/plain
|
tests/test/tgeneric13.pp svneol=native#text/plain
|
||||||
|
tests/test/tgeneric14.pp svneol=native#text/plain
|
||||||
tests/test/tgeneric2.pp svneol=native#text/plain
|
tests/test/tgeneric2.pp svneol=native#text/plain
|
||||||
tests/test/tgeneric3.pp svneol=native#text/plain
|
tests/test/tgeneric3.pp svneol=native#text/plain
|
||||||
tests/test/tgeneric4.pp svneol=native#text/plain
|
tests/test/tgeneric4.pp svneol=native#text/plain
|
||||||
@ -6925,6 +6926,7 @@ tests/test/uabstrcl.pp svneol=native#text/plain
|
|||||||
tests/test/uenum2a.pp svneol=native#text/plain
|
tests/test/uenum2a.pp svneol=native#text/plain
|
||||||
tests/test/uenum2b.pp svneol=native#text/plain
|
tests/test/uenum2b.pp svneol=native#text/plain
|
||||||
tests/test/ugeneric10.pp svneol=native#text/plain
|
tests/test/ugeneric10.pp svneol=native#text/plain
|
||||||
|
tests/test/ugeneric14.pp svneol=native#text/plain
|
||||||
tests/test/ugeneric3.pp svneol=native#text/plain
|
tests/test/ugeneric3.pp svneol=native#text/plain
|
||||||
tests/test/ugeneric4.pp svneol=native#text/plain
|
tests/test/ugeneric4.pp svneol=native#text/plain
|
||||||
tests/test/uimpluni1.pp svneol=native#text/plain
|
tests/test/uimpluni1.pp svneol=native#text/plain
|
||||||
|
24
tests/test/tgeneric14.pp
Normal file
24
tests/test/tgeneric14.pp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
{ we test the context sensitivity of generics here, by checking whether names
|
||||||
|
are looked up at specialization or at definition time }
|
||||||
|
|
||||||
|
uses
|
||||||
|
ugeneric14;
|
||||||
|
|
||||||
|
const
|
||||||
|
Foo = 4;
|
||||||
|
|
||||||
|
type
|
||||||
|
TIntTest = specialize TGTest<Integer>;
|
||||||
|
|
||||||
|
var
|
||||||
|
A: TIntTest;
|
||||||
|
begin
|
||||||
|
A := TIntTest.Create;
|
||||||
|
A.DoSomething;
|
||||||
|
writeln(A.data);
|
||||||
|
if A.data = 4 then
|
||||||
|
halt(1);
|
||||||
|
A.Free;
|
||||||
|
end.
|
27
tests/test/ugeneric14.pp
Normal file
27
tests/test/ugeneric14.pp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
unit ugeneric14;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
type
|
||||||
|
generic TGTest<T> = class
|
||||||
|
public
|
||||||
|
data: T;
|
||||||
|
procedure DoSomething;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function Foo: Integer;
|
||||||
|
begin
|
||||||
|
writeln('foo');
|
||||||
|
Result := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGTest.DoSomething;
|
||||||
|
begin
|
||||||
|
data := Foo;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user