* test for subrangeset

git-svn-id: trunk@27748 -
This commit is contained in:
michael 2014-05-10 15:24:31 +00:00
parent c861384366
commit 89c4255ab8

View File

@ -131,6 +131,7 @@ type
Procedure TestComplexSetDeprecated; Procedure TestComplexSetDeprecated;
Procedure TestComplexSetPlatform; Procedure TestComplexSetPlatform;
Procedure TestRangeSet; Procedure TestRangeSet;
Procedure TestSubRangeSet;
Procedure TestRangeSetDeprecated; Procedure TestRangeSetDeprecated;
Procedure TestRangeSetPlatform; Procedure TestRangeSetPlatform;
Procedure TestClassOf; Procedure TestClassOf;
@ -2155,8 +2156,8 @@ end;
{ TTestTypeParser } { TTestTypeParser }
procedure TTestTypeParser.DoTestAliasType(const AnAliasType: String; Procedure TTestTypeParser.DoTestAliasType(Const AnAliasType: String;
const AHint: String); Const AHint: String);
begin begin
ParseType(AnAliasType,TPasAliasType,AHint); ParseType(AnAliasType,TPasAliasType,AHint);
AssertEquals('Unresolved type',TPasUnresolvedTypeRef,TPasAliasType(TheType).DestType.ClassType); AssertEquals('Unresolved type',TPasUnresolvedTypeRef,TPasAliasType(TheType).DestType.ClassType);
@ -2176,13 +2177,13 @@ begin
AssertException(AMsg,EParserError,@DoParseError); AssertException(AMsg,EParserError,@DoParseError);
end; end;
procedure TTestTypeParser.DoParseError; Procedure TTestTypeParser.DoParseError;
begin begin
ParseType(FErrorSource,Nil); ParseType(FErrorSource,Nil);
end; end;
procedure TTestTypeParser.DoParsePointer(const ASource: String; Procedure TTestTypeParser.DoParsePointer(Const ASource: String;
const AHint: String; ADestType: TClass); Const AHint: String; ADestType: TClass);
begin begin
ParseType('^'+ASource,TPasPointerType,AHint); ParseType('^'+ASource,TPasPointerType,AHint);
@ -2191,8 +2192,8 @@ begin
AssertEquals('Destination type '+ADestType.ClassName,ADestType,TPasPointerType(TheType).DestType.ClassType); AssertEquals('Destination type '+ADestType.ClassName,ADestType,TPasPointerType(TheType).DestType.ClassType);
end; end;
procedure TTestTypeParser.DoParseArray(const ASource: String; Procedure TTestTypeParser.DoParseArray(Const ASource: String;
const AHint: String; ADestType: TClass); Const AHint: String; ADestType: TClass);
begin begin
ParseType(ASource,TPasArrayType,AHint); ParseType(ASource,TPasArrayType,AHint);
if ADestType = Nil then if ADestType = Nil then
@ -2200,8 +2201,8 @@ begin
AssertEquals('Destination type '+ADestType.ClassName,ADestType,TPasArrayType(TheType).ElType.ClassType); AssertEquals('Destination type '+ADestType.ClassName,ADestType,TPasArrayType(TheType).ElType.ClassType);
end; end;
procedure TTestTypeParser.DoParseEnumerated(const ASource: String; Procedure TTestTypeParser.DoParseEnumerated(Const ASource: String;
const AHint: String; ACount: integer); Const AHint: String; ACount: integer);
Var Var
I : Integer; I : Integer;
@ -2214,8 +2215,8 @@ begin
AssertEquals('Enum value typed element '+IntToStr(I),TPasEnumValue,TObject(TPasEnumType(TheType).Values[i]).ClassType); AssertEquals('Enum value typed element '+IntToStr(I),TPasEnumValue,TObject(TPasEnumType(TheType).Values[i]).ClassType);
end; end;
procedure TTestTypeParser.DoTestFileType(const AType: String; Procedure TTestTypeParser.DoTestFileType(Const AType: String;
const AHint: String; ADestType: TClass); Const AHint: String; ADestType: TClass);
begin begin
ParseType('File of '+AType,TPasFileType,AHint); ParseType('File of '+AType,TPasFileType,AHint);
AssertNotNull('Have element type',TPasFileType(TheType).ElType); AssertNotNull('Have element type',TPasFileType(TheType).ElType);
@ -2224,23 +2225,23 @@ begin
AssertEquals('Element type '+ADestType.ClassName,ADestType,TPasFileType(TheType).ElType.ClassType); AssertEquals('Element type '+ADestType.ClassName,ADestType,TPasFileType(TheType).ElType.ClassType);
end; end;
procedure TTestTypeParser.DoTestRangeType(const AStart, AStop, AHint: String); Procedure TTestTypeParser.DoTestRangeType(Const AStart, AStop, AHint: String);
begin begin
ParseType(AStart+'..'+AStop,TPasRangeType,AHint); ParseType(AStart+'..'+AStop,TPasRangeType,AHint);
AssertEquals('Range start',AStart,TPasRangeType(TheType).RangeStart); AssertEquals('Range start',AStart,TPasRangeType(TheType).RangeStart);
AssertEquals('Range start',AStop,TPasRangeType(TheType).RangeEnd); AssertEquals('Range start',AStop,TPasRangeType(TheType).RangeEnd);
end; end;
procedure TTestTypeParser.DoParseSimpleSet(const ASource: String; Procedure TTestTypeParser.DoParseSimpleSet(Const ASource: String;
const AHint: String); Const AHint: String);
begin begin
ParseType('Set of '+ASource,TPasSetType,AHint); ParseType('Set of '+ASource,TPasSetType,AHint);
AssertNotNull('Have enumtype',TPasSetType(TheType).EnumType); AssertNotNull('Have enumtype',TPasSetType(TheType).EnumType);
AssertEquals('Element type ',TPasUnresolvedTypeRef,TPasSetType(TheType).EnumType.ClassType); AssertEquals('Element type ',TPasUnresolvedTypeRef,TPasSetType(TheType).EnumType.ClassType);
end; end;
procedure TTestTypeParser.DoParseComplexSet(const ASource: String; Procedure TTestTypeParser.DoParseComplexSet(Const ASource: String;
const AHint: String); Const AHint: String);
begin begin
ParseType('Set of '+ASource,TPasSetType,AHint); ParseType('Set of '+ASource,TPasSetType,AHint);
@ -2257,7 +2258,7 @@ begin
AssertEquals('Element type ',TPasRangeType,TPasSetType(TheType).EnumType.ClassType); AssertEquals('Element type ',TPasRangeType,TPasSetType(TheType).EnumType.ClassType);
end; end;
procedure TTestTypeParser.DoTestComplexSet; Procedure TTestTypeParser.DoTestComplexSet;
Var Var
I : integer; I : integer;
@ -2275,7 +2276,7 @@ begin
AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TPasSetType(TheType).EnumType).Values[2]).AssignedValue); AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TPasSetType(TheType).EnumType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.DoTestClassOf(const AHint: string); Procedure TTestTypeParser.DoTestClassOf(Const AHint: string);
begin begin
ParseType('Class of TSomeClass',TPasClassOfType,AHint); ParseType('Class of TSomeClass',TPasClassOfType,AHint);
@ -2283,278 +2284,278 @@ begin
AssertEquals('Element type ',TPasUnresolvedTypeRef,TPasClassOfType(TheType).DestType.ClassType); AssertEquals('Element type ',TPasUnresolvedTypeRef,TPasClassOfType(TheType).DestType.ClassType);
end; end;
procedure TTestTypeParser.TestAliasType; Procedure TTestTypeParser.TestAliasType;
begin begin
DoTestAliasType('othertype',''); DoTestAliasType('othertype','');
AssertEquals('Unresolved type name ','othertype',TPasUnresolvedTypeRef(TPasAliasType(TheType).DestType).name); AssertEquals('Unresolved type name ','othertype',TPasUnresolvedTypeRef(TPasAliasType(TheType).DestType).name);
end; end;
procedure TTestTypeParser.TestCrossUnitAliasType; Procedure TTestTypeParser.TestCrossUnitAliasType;
begin begin
DoTestAliasType('otherunit.othertype',''); DoTestAliasType('otherunit.othertype','');
end; end;
procedure TTestTypeParser.TestAliasTypeDeprecated; Procedure TTestTypeParser.TestAliasTypeDeprecated;
begin begin
DoTestALiasType('othertype','deprecated'); DoTestALiasType('othertype','deprecated');
end; end;
procedure TTestTypeParser.TestAliasTypePlatform; Procedure TTestTypeParser.TestAliasTypePlatform;
begin begin
DoTestALiasType('othertype','platform'); DoTestALiasType('othertype','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeByte; Procedure TTestTypeParser.TestSimpleTypeByte;
begin begin
DoTestAliasType('BYTE',''); DoTestAliasType('BYTE','');
end; end;
procedure TTestTypeParser.TestSimpleTypeByteDeprecated; Procedure TTestTypeParser.TestSimpleTypeByteDeprecated;
begin begin
DoTestAliasType('BYTE','deprecated'); DoTestAliasType('BYTE','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeBytePlatform; Procedure TTestTypeParser.TestSimpleTypeBytePlatform;
begin begin
DoTestAliasType('BYTE','platform'); DoTestAliasType('BYTE','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeBoolean; Procedure TTestTypeParser.TestSimpleTypeBoolean;
begin begin
DoTestAliasType('BOOLEAN',''); DoTestAliasType('BOOLEAN','');
end; end;
procedure TTestTypeParser.TestSimpleTypeBooleanDeprecated; Procedure TTestTypeParser.TestSimpleTypeBooleanDeprecated;
begin begin
DoTestAliasType('BOOLEAN','deprecated'); DoTestAliasType('BOOLEAN','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeBooleanPlatform; Procedure TTestTypeParser.TestSimpleTypeBooleanPlatform;
begin begin
DoTestAliasType('BOOLEAN','platform'); DoTestAliasType('BOOLEAN','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeChar; Procedure TTestTypeParser.TestSimpleTypeChar;
begin begin
DoTestAliasType('CHAR',''); DoTestAliasType('CHAR','');
end; end;
procedure TTestTypeParser.TestSimpleTypeCharDeprecated; Procedure TTestTypeParser.TestSimpleTypeCharDeprecated;
begin begin
DoTestAliasType('CHAR','deprecated'); DoTestAliasType('CHAR','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeCharPlatform; Procedure TTestTypeParser.TestSimpleTypeCharPlatform;
begin begin
DoTestAliasType('CHAR','platform'); DoTestAliasType('CHAR','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeInteger; Procedure TTestTypeParser.TestSimpleTypeInteger;
begin begin
DoTestAliasType('INTEGER',''); DoTestAliasType('INTEGER','');
end; end;
procedure TTestTypeParser.TestSimpleTypeIntegerDeprecated; Procedure TTestTypeParser.TestSimpleTypeIntegerDeprecated;
begin begin
DoTestAliasType('INTEGER','deprecated'); DoTestAliasType('INTEGER','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeIntegerPlatform; Procedure TTestTypeParser.TestSimpleTypeIntegerPlatform;
begin begin
DoTestAliasType('INTEGER','platform'); DoTestAliasType('INTEGER','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeInt64; Procedure TTestTypeParser.TestSimpleTypeInt64;
begin begin
DoTestAliasType('INT64',''); DoTestAliasType('INT64','');
end; end;
procedure TTestTypeParser.TestSimpleTypeInt64Deprecated; Procedure TTestTypeParser.TestSimpleTypeInt64Deprecated;
begin begin
DoTestAliasType('INT64','deprecated'); DoTestAliasType('INT64','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeInt64Platform; Procedure TTestTypeParser.TestSimpleTypeInt64Platform;
begin begin
DoTestAliasType('INT64','platform'); DoTestAliasType('INT64','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongInt; Procedure TTestTypeParser.TestSimpleTypeLongInt;
begin begin
DoTestAliasType('LONGINT',''); DoTestAliasType('LONGINT','');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongIntDeprecated; Procedure TTestTypeParser.TestSimpleTypeLongIntDeprecated;
begin begin
DoTestAliasType('LONGINT','deprecated'); DoTestAliasType('LONGINT','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongIntPlatform; Procedure TTestTypeParser.TestSimpleTypeLongIntPlatform;
begin begin
DoTestAliasType('LONGINT','platform'); DoTestAliasType('LONGINT','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongWord; Procedure TTestTypeParser.TestSimpleTypeLongWord;
begin begin
DoTestAliasType('LONGWORD',''); DoTestAliasType('LONGWORD','');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongWordDeprecated; Procedure TTestTypeParser.TestSimpleTypeLongWordDeprecated;
begin begin
DoTestAliasType('LONGWORD','deprecated'); DoTestAliasType('LONGWORD','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeLongWordPlatform; Procedure TTestTypeParser.TestSimpleTypeLongWordPlatform;
begin begin
DoTestAliasType('LONGWORD','platform'); DoTestAliasType('LONGWORD','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeDouble; Procedure TTestTypeParser.TestSimpleTypeDouble;
begin begin
DoTestAliasType('Double',''); DoTestAliasType('Double','');
end; end;
procedure TTestTypeParser.TestSimpleTypeDoubleDeprecated; Procedure TTestTypeParser.TestSimpleTypeDoubleDeprecated;
begin begin
DoTestAliasType('Double','deprecated'); DoTestAliasType('Double','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeDoublePlatform; Procedure TTestTypeParser.TestSimpleTypeDoublePlatform;
begin begin
DoTestAliasType('Double','platform'); DoTestAliasType('Double','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeShortInt; Procedure TTestTypeParser.TestSimpleTypeShortInt;
begin begin
DoTestAliasType('SHORTINT',''); DoTestAliasType('SHORTINT','');
end; end;
procedure TTestTypeParser.TestSimpleTypeShortIntDeprecated; Procedure TTestTypeParser.TestSimpleTypeShortIntDeprecated;
begin begin
DoTestAliasType('SHORTINT','deprecated'); DoTestAliasType('SHORTINT','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeShortIntPlatform; Procedure TTestTypeParser.TestSimpleTypeShortIntPlatform;
begin begin
DoTestAliasType('SHORTINT','platform'); DoTestAliasType('SHORTINT','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeSmallInt; Procedure TTestTypeParser.TestSimpleTypeSmallInt;
begin begin
DoTestAliasType('SMALLINT',''); DoTestAliasType('SMALLINT','');
end; end;
procedure TTestTypeParser.TestSimpleTypeSmallIntDeprecated; Procedure TTestTypeParser.TestSimpleTypeSmallIntDeprecated;
begin begin
DoTestAliasType('SMALLINT','deprecated'); DoTestAliasType('SMALLINT','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeSmallIntPlatform; Procedure TTestTypeParser.TestSimpleTypeSmallIntPlatform;
begin begin
DoTestAliasType('SMALLINT','platform'); DoTestAliasType('SMALLINT','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeString; Procedure TTestTypeParser.TestSimpleTypeString;
begin begin
DoTestAliasType('STRING',''); DoTestAliasType('STRING','');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringDeprecated; Procedure TTestTypeParser.TestSimpleTypeStringDeprecated;
begin begin
DoTestAliasType('STRING','deprecated'); DoTestAliasType('STRING','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringPlatform; Procedure TTestTypeParser.TestSimpleTypeStringPlatform;
begin begin
DoTestAliasType('STRING','platform'); DoTestAliasType('STRING','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringSize; Procedure TTestTypeParser.TestSimpleTypeStringSize;
begin begin
DoTestStringType('String[10]',''); DoTestStringType('String[10]','');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringSizeIncomplete; Procedure TTestTypeParser.TestSimpleTypeStringSizeIncomplete;
begin begin
DoTypeError('Incomplete string: missing ]','string[10'); DoTypeError('Incomplete string: missing ]','string[10');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringSizeWrong; Procedure TTestTypeParser.TestSimpleTypeStringSizeWrong;
begin begin
DoTypeError('Incomplete string, ) instead of ]','string[10)'); DoTypeError('Incomplete string, ) instead of ]','string[10)');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringSizeDeprecated; Procedure TTestTypeParser.TestSimpleTypeStringSizeDeprecated;
begin begin
DoTestStringType('String[10]','deprecated'); DoTestStringType('String[10]','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeStringSizePlatform; Procedure TTestTypeParser.TestSimpleTypeStringSizePlatform;
begin begin
DoTestStringType('String[10]','Platform'); DoTestStringType('String[10]','Platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeWord; Procedure TTestTypeParser.TestSimpleTypeWord;
BEGIN BEGIN
DoTestAliasType('WORD',''); DoTestAliasType('WORD','');
end; end;
procedure TTestTypeParser.TestSimpleTypeWordDeprecated; Procedure TTestTypeParser.TestSimpleTypeWordDeprecated;
begin begin
DoTestAliasType('WORD','deprecated'); DoTestAliasType('WORD','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeWordPlatform; Procedure TTestTypeParser.TestSimpleTypeWordPlatform;
begin begin
DoTestAliasType('WORD','platform'); DoTestAliasType('WORD','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeQWord; Procedure TTestTypeParser.TestSimpleTypeQWord;
BEGIN BEGIN
DoTestAliasType('QWORD',''); DoTestAliasType('QWORD','');
end; end;
procedure TTestTypeParser.TestSimpleTypeQWordDeprecated; Procedure TTestTypeParser.TestSimpleTypeQWordDeprecated;
begin begin
DoTestAliasType('QWORD','deprecated'); DoTestAliasType('QWORD','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeQWordPlatform; Procedure TTestTypeParser.TestSimpleTypeQWordPlatform;
begin begin
DoTestAliasType('QWORD','platform'); DoTestAliasType('QWORD','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeCardinal; Procedure TTestTypeParser.TestSimpleTypeCardinal;
begin begin
DoTestAliasType('CARDINAL',''); DoTestAliasType('CARDINAL','');
end; end;
procedure TTestTypeParser.TestSimpleTypeCardinalDeprecated; Procedure TTestTypeParser.TestSimpleTypeCardinalDeprecated;
begin begin
DoTestAliasType('CARDINAL','deprecated'); DoTestAliasType('CARDINAL','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeCardinalPlatform; Procedure TTestTypeParser.TestSimpleTypeCardinalPlatform;
begin begin
DoTestAliasType('CARDINAL','platform'); DoTestAliasType('CARDINAL','platform');
end; end;
procedure TTestTypeParser.TestSimpleTypeWideChar; Procedure TTestTypeParser.TestSimpleTypeWideChar;
begin begin
DoTestAliasType('WIDECHAR',''); DoTestAliasType('WIDECHAR','');
end; end;
procedure TTestTypeParser.TestSimpleTypeWideCharDeprecated; Procedure TTestTypeParser.TestSimpleTypeWideCharDeprecated;
begin begin
DoTestAliasType('WIDECHAR','deprecated'); DoTestAliasType('WIDECHAR','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleTypeWideCharPlatform; Procedure TTestTypeParser.TestSimpleTypeWideCharPlatform;
begin begin
DoTestAliasType('WIDECHAR','platform'); DoTestAliasType('WIDECHAR','platform');
end; end;
procedure TTestTypeParser.TestPointerSimple; Procedure TTestTypeParser.TestPointerSimple;
begin begin
DoParsePointer('integer',''); DoParsePointer('integer','');
end; end;
@ -2569,7 +2570,7 @@ begin
DoParsePointer('integer','platform'); DoParsePointer('integer','platform');
end; end;
procedure TTestTypeParser.TestStaticArray; Procedure TTestTypeParser.TestStaticArray;
begin begin
DoParseArray('array [0..2] of integer','',Nil); DoParseArray('array [0..2] of integer','',Nil);
AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange); AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange);
@ -2587,26 +2588,26 @@ begin
AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange); AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange);
end; end;
procedure TTestTypeParser.TestStaticArrayPacked; Procedure TTestTypeParser.TestStaticArrayPacked;
begin begin
DoParseArray('packed array [0..2] of integer','',Nil); DoParseArray('packed array [0..2] of integer','',Nil);
AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange); AssertEquals('Array type','0..2',TPasArrayType(TheType).IndexRange);
AssertEquals('Packed',True,TPasArrayType(TheType).IsPacked); AssertEquals('Packed',True,TPasArrayType(TheType).IsPacked);
end; end;
procedure TTestTypeParser.TestStaticArrayTypedIndex; Procedure TTestTypeParser.TestStaticArrayTypedIndex;
begin begin
DoParseArray('array [Boolean] of integer','',Nil); DoParseArray('array [Boolean] of integer','',Nil);
AssertEquals('Array type','Boolean',TPasArrayType(TheType).IndexRange); AssertEquals('Array type','Boolean',TPasArrayType(TheType).IndexRange);
end; end;
procedure TTestTypeParser.TestDynamicArray; Procedure TTestTypeParser.TestDynamicArray;
begin begin
DoParseArray('array of integer','',Nil); DoParseArray('array of integer','',Nil);
AssertEquals('Array type','',TPasArrayType(TheType).IndexRange); AssertEquals('Array type','',TPasArrayType(TheType).IndexRange);
end; end;
procedure TTestTypeParser.TestSimpleEnumerated; Procedure TTestTypeParser.TestSimpleEnumerated;
begin begin
DoParseEnumerated('(one,two,three)','',3); DoParseEnumerated('(one,two,three)','',3);
@ -2618,7 +2619,7 @@ begin
AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestSimpleEnumeratedDeprecated; Procedure TTestTypeParser.TestSimpleEnumeratedDeprecated;
begin begin
DoParseEnumerated('(one,two,three)','deprecated',3); DoParseEnumerated('(one,two,three)','deprecated',3);
AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name); AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name);
@ -2629,7 +2630,7 @@ begin
AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestSimpleEnumeratedPlatform; Procedure TTestTypeParser.TestSimpleEnumeratedPlatform;
begin begin
DoParseEnumerated('(one,two,three)','platform',3); DoParseEnumerated('(one,two,three)','platform',3);
AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name); AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name);
@ -2640,7 +2641,7 @@ begin
AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value third enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestAssignedEnumerated; Procedure TTestTypeParser.TestAssignedEnumerated;
begin begin
DoParseEnumerated('(one,two:=2,three)','',3); DoParseEnumerated('(one,two:=2,three)','',3);
AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name); AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name);
@ -2651,7 +2652,7 @@ begin
AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestAssignedEnumeratedDeprecated; Procedure TTestTypeParser.TestAssignedEnumeratedDeprecated;
begin begin
DoParseEnumerated('(one,two:=2,three)','',3); DoParseEnumerated('(one,two:=2,three)','',3);
AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name); AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name);
@ -2662,7 +2663,7 @@ begin
AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestAssignedEnumeratedPlatform; Procedure TTestTypeParser.TestAssignedEnumeratedPlatform;
begin begin
DoParseEnumerated('(one,two:=2,three)','',3); DoParseEnumerated('(one,two:=2,three)','',3);
AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name); AssertEquals('First enumerated value','one',TPasEnumValue(TPasEnumType(TheType).Values[0]).Name);
@ -2673,73 +2674,73 @@ begin
AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue); AssertEquals('Assigned value first enumerated empty','',TPasEnumValue(TPasEnumType(TheType).Values[2]).AssignedValue);
end; end;
procedure TTestTypeParser.TestFileType; Procedure TTestTypeParser.TestFileType;
begin begin
DoTestFileType('integer',''); DoTestFileType('integer','');
end; end;
procedure TTestTypeParser.TestFileTypeDeprecated; Procedure TTestTypeParser.TestFileTypeDeprecated;
begin begin
DoTestFileType('integer','deprecated'); DoTestFileType('integer','deprecated');
end; end;
procedure TTestTypeParser.TestFileTypePlatform; Procedure TTestTypeParser.TestFileTypePlatform;
begin begin
DoTestFileType('integer','platform'); DoTestFileType('integer','platform');
end; end;
procedure TTestTypeParser.TestRangeType; Procedure TTestTypeParser.TestRangeType;
begin begin
DoTestRangeType('1','4',''); DoTestRangeType('1','4','');
end; end;
procedure TTestTypeParser.TestRangeTypeDeprecated; Procedure TTestTypeParser.TestRangeTypeDeprecated;
begin begin
DoTestRangeType('1','4','deprecated'); DoTestRangeType('1','4','deprecated');
end; end;
procedure TTestTypeParser.TestRangeTypePlatform; Procedure TTestTypeParser.TestRangeTypePlatform;
begin begin
DoTestRangeType('1','4','platform'); DoTestRangeType('1','4','platform');
end; end;
procedure TTestTypeParser.TestIdentifierRangeType; Procedure TTestTypeParser.TestIdentifierRangeType;
begin begin
DoTestRangeType('tkFirst','tkLast',''); DoTestRangeType('tkFirst','tkLast','');
end; end;
procedure TTestTypeParser.TestIdentifierRangeTypeDeprecated; Procedure TTestTypeParser.TestIdentifierRangeTypeDeprecated;
begin begin
DoTestRangeType('tkFirst','tkLast','deprecated'); DoTestRangeType('tkFirst','tkLast','deprecated');
end; end;
procedure TTestTypeParser.TestIdentifierRangeTypePlatform; Procedure TTestTypeParser.TestIdentifierRangeTypePlatform;
begin begin
DoTestRangeType('tkFirst','tkLast','platform'); DoTestRangeType('tkFirst','tkLast','platform');
end; end;
procedure TTestTypeParser.TestNegativeIdentifierRangeType; Procedure TTestTypeParser.TestNegativeIdentifierRangeType;
begin begin
DoTestRangeType('-tkLast','tkLast',''); DoTestRangeType('-tkLast','tkLast','');
end; end;
procedure TTestTypeParser.TestSimpleSet; Procedure TTestTypeParser.TestSimpleSet;
begin begin
DoParseSimpleSet('Byte',''); DoParseSimpleSet('Byte','');
end; end;
procedure TTestTypeParser.TestSimpleSetDeprecated; Procedure TTestTypeParser.TestSimpleSetDeprecated;
begin begin
DoParseSimpleSet('Byte','deprecated'); DoParseSimpleSet('Byte','deprecated');
end; end;
procedure TTestTypeParser.TestSimpleSetPlatform; Procedure TTestTypeParser.TestSimpleSetPlatform;
begin begin
DoParseSimpleSet('Byte','platform'); DoParseSimpleSet('Byte','platform');
end; end;
procedure TTestTypeParser.TestComplexSet; Procedure TTestTypeParser.TestComplexSet;
begin begin
@ -2747,51 +2748,57 @@ begin
DoTestComplexSet; DoTestComplexSet;
end; end;
procedure TTestTypeParser.TestComplexSetDeprecated; Procedure TTestTypeParser.TestComplexSetDeprecated;
begin begin
DoParseComplexSet('(one, two, three)','deprecated'); DoParseComplexSet('(one, two, three)','deprecated');
DoTestComplexSet; DoTestComplexSet;
end; end;
procedure TTestTypeParser.TestComplexSetPlatform; Procedure TTestTypeParser.TestComplexSetPlatform;
begin begin
DoParseComplexSet('(one, two, three)','platform'); DoParseComplexSet('(one, two, three)','platform');
DoTestComplexSet; DoTestComplexSet;
end; end;
procedure TTestTypeParser.TestRangeSet; Procedure TTestTypeParser.TestRangeSet;
begin
// TRange = (rLow, rMiddle, rHigh);
DoParseRangeSet('rMiddle..high(TRange)','');
end;
Procedure TTestTypeParser.TestSubRangeSet;
begin begin
DoParseRangeSet('0..SizeOf(Integer)*8-1',''); DoParseRangeSet('0..SizeOf(Integer)*8-1','');
end; end;
procedure TTestTypeParser.TestRangeSetDeprecated; Procedure TTestTypeParser.TestRangeSetDeprecated;
begin begin
DoParseRangeSet('0..SizeOf(Integer)*8-1','deprecated'); DoParseRangeSet('0..SizeOf(Integer)*8-1','deprecated');
end; end;
procedure TTestTypeParser.TestRangeSetPlatform; Procedure TTestTypeParser.TestRangeSetPlatform;
begin begin
DoParseRangeSet('0..SizeOf(Integer)*8-1','platform'); DoParseRangeSet('0..SizeOf(Integer)*8-1','platform');
end; end;
procedure TTestTypeParser.TestClassOf; Procedure TTestTypeParser.TestClassOf;
begin begin
DoTestClassOf(''); DoTestClassOf('');
end; end;
procedure TTestTypeParser.TestClassOfDeprecated; Procedure TTestTypeParser.TestClassOfDeprecated;
begin begin
DoTestClassOf('deprecated'); DoTestClassOf('deprecated');
end; end;
procedure TTestTypeParser.TestClassOfPlatform; Procedure TTestTypeParser.TestClassOfPlatform;
begin begin
DoTestClassOf('Platform'); DoTestClassOf('Platform');
end; end;
procedure TTestTypeParser.TestReferenceAlias; Procedure TTestTypeParser.TestReferenceAlias;
begin begin
Add('Type'); Add('Type');
Add(' Type1 = Integer;'); Add(' Type1 = Integer;');
@ -2806,7 +2813,7 @@ begin
AssertSame('Second declaration references first.',Declarations.Types[0],TPasAliasType(Declarations.Types[1]).DestType); AssertSame('Second declaration references first.',Declarations.Types[0],TPasAliasType(Declarations.Types[1]).DestType);
end; end;
procedure TTestTypeParser.TestReferenceSet; Procedure TTestTypeParser.TestReferenceSet;
begin begin
Add('Type'); Add('Type');
@ -2822,7 +2829,7 @@ begin
AssertSame('Second declaration references first.',Declarations.Types[0],TPasSetType(Declarations.Types[1]).EnumType); AssertSame('Second declaration references first.',Declarations.Types[0],TPasSetType(Declarations.Types[1]).EnumType);
end; end;
procedure TTestTypeParser.TestReferenceClassOf; Procedure TTestTypeParser.TestReferenceClassOf;
begin begin
Add('Type'); Add('Type');
Add(' Type1 = Class(TObject);'); Add(' Type1 = Class(TObject);');
@ -2838,7 +2845,7 @@ begin
AssertSame('Second declaration references first.',Declarations.Classes[0],TPasClassOfType(Declarations.Types[0]).DestType); AssertSame('Second declaration references first.',Declarations.Classes[0],TPasClassOfType(Declarations.Types[0]).DestType);
end; end;
procedure TTestTypeParser.TestReferenceFile; Procedure TTestTypeParser.TestReferenceFile;
begin begin
Add('Type'); Add('Type');
Add(' Type1 = (a,b,c);'); Add(' Type1 = (a,b,c);');
@ -2853,7 +2860,7 @@ begin
AssertSame('Second declaration references first.',Declarations.Types[0],TPasFileType(Declarations.Types[1]).elType); AssertSame('Second declaration references first.',Declarations.Types[0],TPasFileType(Declarations.Types[1]).elType);
end; end;
procedure TTestTypeParser.TestReferenceArray; Procedure TTestTypeParser.TestReferenceArray;
begin begin
Add('Type'); Add('Type');
Add(' Type1 = (a,b,c);'); Add(' Type1 = (a,b,c);');
@ -2868,7 +2875,7 @@ begin
AssertSame('Second declaration references first.',Declarations.Types[0],TPasArrayType(Declarations.Types[1]).elType); AssertSame('Second declaration references first.',Declarations.Types[0],TPasArrayType(Declarations.Types[1]).elType);
end; end;
procedure TTestTypeParser.TestReferencePointer; Procedure TTestTypeParser.TestReferencePointer;
begin begin
Add('Type'); Add('Type');
Add(' Type1 = (a,b,c);'); Add(' Type1 = (a,b,c);');