mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
codetools: started test pas writer
git-svn-id: trunk@56096 -
This commit is contained in:
parent
f483ea123d
commit
1b5c47c94c
@ -37,7 +37,7 @@
|
|||||||
<PackageName Value="fpcunitconsolerunner"/>
|
<PackageName Value="fpcunitconsolerunner"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="12">
|
<Units Count="13">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="runtestscodetools.lpr"/>
|
<Filename Value="runtestscodetools.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -94,6 +94,11 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="TestCodeCompletion"/>
|
<UnitName Value="TestCodeCompletion"/>
|
||||||
</Unit11>
|
</Unit11>
|
||||||
|
<Unit12>
|
||||||
|
<Filename Value="testcompreaderwriterpas.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="TestCompReaderWriterPas"/>
|
||||||
|
</Unit12>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -36,9 +36,9 @@ uses
|
|||||||
{$IFDEF Darwin}
|
{$IFDEF Darwin}
|
||||||
fdt_objccategory, fdt_objcclass,
|
fdt_objccategory, fdt_objcclass,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TestBasicCodetools,
|
TestBasicCodetools, TestCTRangeScan, TestPascalParser, TestMethodJumpTool,
|
||||||
TestCTRangeScan, TestPascalParser, TestMethodJumpTool, TestStdCodetools,
|
TestStdCodetools, TestFindDeclaration, TestCompleteBlock, TestRefactoring,
|
||||||
TestFindDeclaration, TestCompleteBlock, TestRefactoring, fdt_arrays, testcodecompletion;
|
fdt_arrays, testcodecompletion, TestCompReaderWriterPas;
|
||||||
|
|
||||||
const
|
const
|
||||||
ConfigFilename = 'codetools.config';
|
ConfigFilename = 'codetools.config';
|
||||||
|
@ -5,11 +5,83 @@ unit TestCompReaderWriterPas;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LazLoggerBase, fpcunit, testregistry,
|
Classes, SysUtils, LazLoggerBase, CompWriterPas, fpcunit, testregistry,
|
||||||
CodeToolManager, CodeCache, LinkScanner,
|
CodeToolManager, LinkScanner,
|
||||||
TestStdCodetools;
|
TestStdCodetools;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TEnum = (red, green, blue, white, black);
|
||||||
|
TEnumRg = green..white;
|
||||||
|
TSetOfEnum = set of TEnum;
|
||||||
|
TSetOfEnumRg = set of TEnumRg;
|
||||||
|
|
||||||
|
{ TCompBaseTypes }
|
||||||
|
|
||||||
|
TCompBaseTypes = class(TComponent)
|
||||||
|
private
|
||||||
|
FABoolean: Boolean;
|
||||||
|
FAByte: Byte;
|
||||||
|
FAByteBool: ByteBool;
|
||||||
|
FAChar: Char;
|
||||||
|
FACurrency: Currency;
|
||||||
|
FADouble: Double;
|
||||||
|
FAExtended: Extended;
|
||||||
|
FAInt64: Int64;
|
||||||
|
FALongBool: LongBool;
|
||||||
|
FALongInt: LongInt;
|
||||||
|
FALongWord: LongWord;
|
||||||
|
FAQWord: QWord;
|
||||||
|
FAShortInt: ShortInt;
|
||||||
|
FAShortString: ShortString;
|
||||||
|
FASingle: Single;
|
||||||
|
FASmallInt: SmallInt;
|
||||||
|
FAString: String;
|
||||||
|
FAUnicodeString: UnicodeString;
|
||||||
|
FAWideChar: WideChar;
|
||||||
|
FAWideString: WideString;
|
||||||
|
FAWord: Word;
|
||||||
|
FAWordBool: WordBool;
|
||||||
|
FEnum: TEnum;
|
||||||
|
FEnumRg: TEnumRg;
|
||||||
|
FSetOfEnum: TSetOfEnum;
|
||||||
|
FSetOfEnumRg: TSetOfEnumRg;
|
||||||
|
function isACurrencyStored: Boolean;
|
||||||
|
function isADoubleStored: Boolean;
|
||||||
|
function isAExtendedStored: Boolean;
|
||||||
|
function isAShortStringStored: Boolean;
|
||||||
|
function isASingleStored: Boolean;
|
||||||
|
function isAStringStored: Boolean;
|
||||||
|
function isAUnicodeStringStored: Boolean;
|
||||||
|
function isAWideStringStored: Boolean;
|
||||||
|
published
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
property ABoolean: Boolean read FABoolean write FABoolean default false;
|
||||||
|
property AByteBool: ByteBool read FAByteBool write FAByteBool default false;
|
||||||
|
property AWordBool: WordBool read FAWordBool write FAWordBool default false;
|
||||||
|
property ALongBool: LongBool read FALongBool write FALongBool default false;
|
||||||
|
property AByte: Byte read FAByte write FAByte default 0;
|
||||||
|
property AShortInt: ShortInt read FAShortInt write FAShortInt default 0;
|
||||||
|
property AWord: Word read FAWord write FAWord default 0;
|
||||||
|
property ASmallInt: SmallInt read FASmallInt write FASmallInt default 0;
|
||||||
|
property ALongWord: LongWord read FALongWord write FALongWord default 0;
|
||||||
|
property ALongInt: LongInt read FALongInt write FALongInt default 0;
|
||||||
|
property AQWord: QWord read FAQWord write FAQWord default 0;
|
||||||
|
property AInt64: Int64 read FAInt64 write FAInt64 default 0;
|
||||||
|
property ACurrency: Currency read FACurrency write FACurrency stored isACurrencyStored;
|
||||||
|
property ASingle: Single read FASingle write FASingle stored isASingleStored;
|
||||||
|
property ADouble: Double read FADouble write FADouble stored isADoubleStored;
|
||||||
|
property AExtended: Extended read FAExtended write FAExtended stored isAExtendedStored;
|
||||||
|
property AChar: Char read FAChar write FAChar default #0;
|
||||||
|
property AWideChar: WideChar read FAWideChar write FAWideChar default #0;
|
||||||
|
property AString: String read FAString write FAString stored isAStringStored;
|
||||||
|
property AShortString: ShortString read FAShortString write FAShortString stored isAShortStringStored;
|
||||||
|
property AWideString: WideString read FAWideString write FAWideString stored isAWideStringStored;
|
||||||
|
property AUnicodeString: UnicodeString read FAUnicodeString write FAUnicodeString stored isAUnicodeStringStored;
|
||||||
|
property Enum: TEnum read FEnum write FEnum default low(TEnum);
|
||||||
|
property EnumRg: TEnumRg read FEnumRg write FEnumRg default low(TEnumRg);
|
||||||
|
property SetOfEnum: TSetOfEnum read FSetOfEnum write FSetOfEnum default [];
|
||||||
|
property SetOfEnumRg: TSetOfEnumRg read FSetOfEnumRg write FSetOfEnumRg default [];
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTestCompReaderWriterPas }
|
{ TTestCompReaderWriterPas }
|
||||||
|
|
||||||
@ -20,11 +92,84 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{ TCompBaseTypes }
|
||||||
|
|
||||||
|
function TCompBaseTypes.isACurrencyStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=ACurrency<>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isADoubleStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=ADouble<>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isAExtendedStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=AExtended<>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isAShortStringStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=AShortString<>'';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isASingleStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=ASingle<>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isAStringStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=AString<>'';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isAUnicodeStringStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=AUnicodeString<>'';
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCompBaseTypes.isAWideStringStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=AWideString<>'';
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCompBaseTypes.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
EnumRg:=low(TEnumRg);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTestCompReaderWriterPas }
|
{ TTestCompReaderWriterPas }
|
||||||
|
|
||||||
procedure TTestCompReaderWriterPas.TestWriteProperties;
|
procedure TTestCompReaderWriterPas.TestWriteProperties;
|
||||||
|
var
|
||||||
|
AComponent: TCompBaseTypes;
|
||||||
|
aStream: TMemoryStream;
|
||||||
|
Actual: string;
|
||||||
|
Driver: TPASObjectWriter;
|
||||||
|
Writer: TWriter;
|
||||||
begin
|
begin
|
||||||
|
Driver:=nil;
|
||||||
|
Writer:=nil;
|
||||||
|
AComponent:=TCompBaseTypes.Create(nil);
|
||||||
|
aStream:=TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
AComponent.Name:=AComponent.ClassName+'1';
|
||||||
|
AComponent.ABoolean:=true;
|
||||||
|
Driver:=TPASObjectWriter.Create(aStream);
|
||||||
|
Writer:=TWriter.Create(Driver);
|
||||||
|
Writer.WriteDescendent(AComponent,nil);
|
||||||
|
aStream.Position:=0;
|
||||||
|
SetLength(Actual,aStream.size);
|
||||||
|
aStream.Read(Actual[1],length(Actual));
|
||||||
|
writeln('TTestCompReaderWriterPas.TestWriteProperties "',Actual,'"');
|
||||||
|
finally
|
||||||
|
aStream.Free;
|
||||||
|
AComponent.Free;
|
||||||
|
Writer.Free;
|
||||||
|
Driver.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Loading…
Reference in New Issue
Block a user