From 82b1642a945b37f2ec49aaf07b943387dcfe69fb Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 1 Oct 2011 12:23:51 +0000 Subject: [PATCH] tests: added program to test method compares git-svn-id: trunk@32580 - --- .gitattributes | 1 + test/lcltests/testmethodcompare.pas | 58 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 test/lcltests/testmethodcompare.pas diff --git a/.gitattributes b/.gitattributes index 62cd8b458a..ff74420370 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5940,6 +5940,7 @@ test/codetoolstests/testcth2pas.pas svneol=native#text/pascal test/codetoolstests/testctrangescan.pas svneol=native#text/plain test/codetoolstests/testctxmlfixfragments.pas svneol=native#text/pascal test/hello.ahk svneol=native#text/plain +test/lcltests/testmethodcompare.pas svneol=native#text/plain test/lcltests/testpen.pas svneol=native#text/plain test/lcltests/testpreferredsize.pas svneol=native#text/plain test/lcltests/testunicode.pas svneol=native#text/plain diff --git a/test/lcltests/testmethodcompare.pas b/test/lcltests/testmethodcompare.pas new file mode 100644 index 0000000000..7136fdefbe --- /dev/null +++ b/test/lcltests/testmethodcompare.pas @@ -0,0 +1,58 @@ +program testmethodcompare; + +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +var + M1, M2: TNotifyEvent; + + procedure WriteReport; + begin + writeln('WriteReport', + ' M1.Data=',PtrUInt(TMethod(M1).Data), + ' M1.Code=',PtrUInt(TMethod(M1).Code), + ' M2.Data=',PtrUInt(TMethod(M2).Data), + ' M2.Code=',PtrUInt(TMethod(M2).Code), + ' Assigned(M1)=',Assigned(M1), + ' Assigned(M2)=',Assigned(M2), + ' M1=nil=',(M1=nil), + ' M2=nil=',(M2=nil), + ' M1<>nil=',(M1<>nil), + ' M2<>nil=',(M2<>nil), + ' M1=M2=',(M1=M2), + ' M1<>M2=',(M1<>M2), + '' + ); + end; + + function Meth(Code, Data: Pointer): TNotifyEvent; + var + m: TMethod; + begin + m.Code:=Code; + m.Data:=Data; + Result:=TNotifyEvent(m); + end; + +begin + M1:=nil; + M2:=nil; + WriteReport; + M1:=Meth(Pointer(1),Pointer(0)); + WriteReport; + M2:=M1; + WriteReport; + M2:=nil; + M1:=Meth(Pointer(0),Pointer(1)); + WriteReport; + M2:=M1; + WriteReport; + M2:=nil; + M1:=Meth(Pointer(1),Pointer(1)); + WriteReport; + M2:=M1; + WriteReport; +end. +