|
@@ -5,7 +5,7 @@ unit tcclasstype;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- Classes, SysUtils, fpcunit, pparser, pastree, testregistry, tctypeparser;
|
|
|
|
|
|
+ Classes, SysUtils, fpcunit, pscanner,pparser, pastree, testregistry, tctypeparser;
|
|
|
|
|
|
type
|
|
type
|
|
|
|
|
|
@@ -30,6 +30,7 @@ type
|
|
function GetT(AIndex : Integer) : TPasType;
|
|
function GetT(AIndex : Integer) : TPasType;
|
|
protected
|
|
protected
|
|
Procedure StartClass (AParent : String = 'TObject'; InterfaceList : String = '');
|
|
Procedure StartClass (AParent : String = 'TObject'; InterfaceList : String = '');
|
|
|
|
+ Procedure StartExternalClass (AParent : String; AExternalName,AExternalNameSpace : String );
|
|
Procedure StartClassHelper (ForType : String = 'TOriginal'; AParent : String = 'TObject');
|
|
Procedure StartClassHelper (ForType : String = 'TOriginal'; AParent : String = 'TObject');
|
|
Procedure StartInterface (AParent : String = 'IInterface'; UUID : String = ''; Disp : Boolean = False);
|
|
Procedure StartInterface (AParent : String = 'IInterface'; UUID : String = ''; Disp : Boolean = False);
|
|
Procedure StartRecordHelper (ForType : String = 'TOriginal'; AParent : String = 'TObject');
|
|
Procedure StartRecordHelper (ForType : String = 'TOriginal'; AParent : String = 'TObject');
|
|
@@ -141,6 +142,10 @@ type
|
|
Procedure TestPropertyReadFromRecordField;
|
|
Procedure TestPropertyReadFromRecordField;
|
|
procedure TestPropertyReadFromArrayField;
|
|
procedure TestPropertyReadFromArrayField;
|
|
procedure TestPropertyReadWriteFromRecordField;
|
|
procedure TestPropertyReadWriteFromRecordField;
|
|
|
|
+ Procedure TestExternalClass;
|
|
|
|
+ Procedure TestExternalClassNoNameSpace;
|
|
|
|
+ Procedure TestExternalClassNoNameKeyWord;
|
|
|
|
+ Procedure TestExternalClassNoName;
|
|
Procedure TestLocalSimpleType;
|
|
Procedure TestLocalSimpleType;
|
|
Procedure TestLocalSimpleTypes;
|
|
Procedure TestLocalSimpleTypes;
|
|
Procedure TestLocalSimpleConst;
|
|
Procedure TestLocalSimpleConst;
|
|
@@ -252,6 +257,21 @@ begin
|
|
FParent:=AParent;
|
|
FParent:=AParent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TTestClassType.StartExternalClass(AParent: String; AExternalName,
|
|
|
|
+ AExternalNameSpace: String);
|
|
|
|
+
|
|
|
|
+Var
|
|
|
|
+ S : String;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ FStarted:=True;
|
|
|
|
+ S:=Format('TMyClass = Class external ''%s'' name ''%s'' ',[AExternalNameSpace,AExternalName]);
|
|
|
|
+ if (AParent<>'') then
|
|
|
|
+ S:=S+'('+AParent+')';
|
|
|
|
+ FDecl.Add(S);
|
|
|
|
+ FParent:=AParent;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TTestClassType.StartClassHelper(ForType: String; AParent: String);
|
|
procedure TTestClassType.StartClassHelper(ForType: String; AParent: String);
|
|
Var
|
|
Var
|
|
S : String;
|
|
S : String;
|
|
@@ -1494,6 +1514,42 @@ begin
|
|
Assertequals('Default value','',Property1.DefaultValue);
|
|
Assertequals('Default value','',Property1.DefaultValue);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TTestClassType.TestExternalClass;
|
|
|
|
+begin
|
|
|
|
+ StartExternalClass('','myname','mynamespace');
|
|
|
|
+ Parser.CurrentModeswitches:=[msObjfpc,msexternalClass];
|
|
|
|
+ ParseClass;
|
|
|
|
+ AssertTrue('External class ',TheClass.IsExternal);
|
|
|
|
+ AssertEquals('External name space','mynamespace',TheClass.ExternalNameSpace);
|
|
|
|
+ AssertEquals('External name ','myname',TheClass.ExternalName);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TTestClassType.TestExternalClassNoNameSpace;
|
|
|
|
+begin
|
|
|
|
+ FStarted:=True;
|
|
|
|
+ Parser.CurrentModeswitches:=[msObjfpc,msexternalClass];
|
|
|
|
+ FDecl.add('TMyClass = Class external name ''me'' ');
|
|
|
|
+ AssertException('No namespace raises error',EParserError,@ParseClass);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TTestClassType.TestExternalClassNoNameKeyWord;
|
|
|
|
+begin
|
|
|
|
+ FStarted:=True;
|
|
|
|
+ Parser.CurrentModeswitches:=[msObjfpc,msexternalClass];
|
|
|
|
+ FDecl.add('TMyClass = Class external ''name'' ''me'' ');
|
|
|
|
+ AssertException('No name keyword raises error',EParserError,@ParseClass);
|
|
|
|
+
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TTestClassType.TestExternalClassNoName;
|
|
|
|
+begin
|
|
|
|
+ FStarted:=True;
|
|
|
|
+ Parser.CurrentModeswitches:=[msObjfpc,msexternalClass];
|
|
|
|
+ FDecl.add('TMyClass = Class external ''name'' name ');
|
|
|
|
+ AssertException('No name raises error',EParserError,@ParseClass);
|
|
|
|
+
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TTestClassType.TestLocalSimpleType;
|
|
procedure TTestClassType.TestLocalSimpleType;
|
|
begin
|
|
begin
|
|
StartVisibility(visPublic);
|
|
StartVisibility(visPublic);
|