diff --git a/components/codetools/tests/runtestscodetools.lpi b/components/codetools/tests/runtestscodetools.lpi
index 819b5345f2..31f669c36f 100644
--- a/components/codetools/tests/runtestscodetools.lpi
+++ b/components/codetools/tests/runtestscodetools.lpi
@@ -37,7 +37,7 @@
-
+
@@ -94,6 +94,11 @@
+
+
+
+
+
diff --git a/components/codetools/tests/runtestscodetools.lpr b/components/codetools/tests/runtestscodetools.lpr
index 43d41c5143..de21807b79 100644
--- a/components/codetools/tests/runtestscodetools.lpr
+++ b/components/codetools/tests/runtestscodetools.lpr
@@ -36,9 +36,9 @@ uses
{$IFDEF Darwin}
fdt_objccategory, fdt_objcclass,
{$ENDIF}
- TestBasicCodetools,
- TestCTRangeScan, TestPascalParser, TestMethodJumpTool, TestStdCodetools,
- TestFindDeclaration, TestCompleteBlock, TestRefactoring, fdt_arrays, testcodecompletion;
+ TestBasicCodetools, TestCTRangeScan, TestPascalParser, TestMethodJumpTool,
+ TestStdCodetools, TestFindDeclaration, TestCompleteBlock, TestRefactoring,
+ fdt_arrays, testcodecompletion, TestCompReaderWriterPas;
const
ConfigFilename = 'codetools.config';
diff --git a/components/codetools/tests/testcompreaderwriterpas.pas b/components/codetools/tests/testcompreaderwriterpas.pas
index 37375cedd1..2b50c71950 100644
--- a/components/codetools/tests/testcompreaderwriterpas.pas
+++ b/components/codetools/tests/testcompreaderwriterpas.pas
@@ -5,11 +5,83 @@ unit TestCompReaderWriterPas;
interface
uses
- Classes, SysUtils, LazLoggerBase, fpcunit, testregistry,
- CodeToolManager, CodeCache, LinkScanner,
+ Classes, SysUtils, LazLoggerBase, CompWriterPas, fpcunit, testregistry,
+ CodeToolManager, LinkScanner,
TestStdCodetools;
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 }
@@ -20,11 +92,84 @@ type
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 }
procedure TTestCompReaderWriterPas.TestWriteProperties;
+var
+ AComponent: TCompBaseTypes;
+ aStream: TMemoryStream;
+ Actual: string;
+ Driver: TPASObjectWriter;
+ Writer: TWriter;
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;
initialization