You've already forked lazarus-ccr
+Object Collection support
All WST custom attributes are now namespace qualified Correct XDS generator for complex type extending simple type git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@520 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -141,20 +141,21 @@ Item0=DUnit
|
||||
Count=1
|
||||
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
[HistoryLists\hlSearchPath]
|
||||
Count=13
|
||||
Count=14
|
||||
Item0=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item1=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\ws_helper
|
||||
Item2=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\fcl-units\fcl-passrc\src
|
||||
Item3=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item4=..\;..\..\;..\..\..\;C:\Programmes\lazarus\wst\trunk\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item5=..\;..\..\;..\..\..\;..\..\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item6=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item7=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;C:\Programmes\lazarus\wst\trunk\ws_helper
|
||||
Item8=..\;..\..\;..\..\..\;..\..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item9=..\;..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item10=..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item11=C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item12=..\
|
||||
Item1=$(DELPHI)\Lib\Debug;C:\PROGRA~1\Borland\Delphi7\MyTools\JVCL\3.20\jcl\lib\d7\debug;..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item2=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\ws_helper
|
||||
Item3=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\fcl-units\fcl-passrc\src
|
||||
Item4=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item5=..\;..\..\;..\..\..\;C:\Programmes\lazarus\wst\trunk\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item6=..\;..\..\;..\..\..\;..\..\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item7=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item8=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;C:\Programmes\lazarus\wst\trunk\ws_helper
|
||||
Item9=..\;..\..\;..\..\..\;..\..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item10=..\;..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item11=..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item12=C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
|
||||
Item13=..\
|
||||
[HistoryLists\hlUnitOutputDirectory]
|
||||
Count=1
|
||||
Item0=obj
|
||||
|
@@ -20,7 +20,10 @@ uses
|
||||
xsd_consts in '..\..\..\ws_helper\xsd_consts.pas',
|
||||
xsd_generator in '..\..\..\ws_helper\xsd_generator.pas',
|
||||
test_generators in '..\test_generators.pas',
|
||||
test_suite_utils in '..\test_suite_utils.pas';
|
||||
test_suite_utils in '..\test_suite_utils.pas',
|
||||
test_std_cursors in '..\test_std_cursors.pas',
|
||||
test_rtti_filter in '..\test_rtti_filter.pas',
|
||||
test_wst_cursors in '..\test_wst_cursors.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
@@ -9,7 +9,10 @@ uses
|
||||
testformatter_unit in '..\testformatter_unit.pas',
|
||||
test_parsers in '..\test_parsers.pas',
|
||||
testmetadata_unit,
|
||||
test_support in '..\test_support.pas';
|
||||
test_support in '..\test_support.pas',
|
||||
test_std_cursors in '..\test_std_cursors.pas',
|
||||
test_rtti_filter in '..\test_rtti_filter.pas',
|
||||
test_wst_cursors in '..\test_wst_cursors.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema xmlns:tns="class_extent_native_type" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="class_extent_native_type">
|
||||
|
||||
<xsd:complexType name="TExtendString">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute use="required" name="intAtt" type="xsd:int"/>
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="TExtendBase64String">
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:base64Binary">
|
||||
<xsd:attribute use="required" name="strAtt" type="xsd:string"/>
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
</schema>
|
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0"?>
|
||||
<definitions name="wst_test"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:tns="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:tns="urn:wst-test"
|
||||
xmlns:wst="urn:wst_base"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:complexType name="TComplexType" />
|
||||
|
||||
<xsd:complexType name="TCollectionComplexType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="field" type="tns:TComplexType" minOccurs="0" maxOccurs="unbounded" wst:wst_collection="true"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="TCollectionItemType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="Item" minOccurs="0" maxOccurs="unbounded" wst:wst_collection="true" >
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
<xsd:element name="floatField" type="xsd:float" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="byteField" type="xsd:byte" maxOccurs="1"/>
|
||||
<xsd:element name="charField" type="xsd:char" minOccurs="1"/>
|
||||
<xsd:element name="longField" type="xsd:long" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="strAtt" type="xsd:string"/>
|
||||
<xsd:attribute name="intAtt" type="xsd:int"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
|
||||
</definitions>
|
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:tns="urn:wst-test"
|
||||
xmlns:wst="urn:wst_base"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:complexType name="TComplexType" />
|
||||
|
||||
<xsd:complexType name="TCollectionComplexType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="field" type="tns:TComplexType" minOccurs="0" maxOccurs="unbounded" wst:wst_collection="true"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="TCollectionItemType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="Item" minOccurs="0" maxOccurs="unbounded" wst:wst_collection="true" >
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
<xsd:element name="floatField" type="xsd:float" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="byteField" type="xsd:byte" maxOccurs="1"/>
|
||||
<xsd:element name="charField" type="xsd:char" minOccurs="1"/>
|
||||
<xsd:element name="longField" type="xsd:long" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="strAtt" type="xsd:string"/>
|
||||
<xsd:attribute name="intAtt" type="xsd:int"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
@@ -7,9 +7,9 @@
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test" xmlns:n="urn:wst-test" >
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wst="urn:wst_base" targetNamespace="urn:wst-test" xmlns:n="urn:wst-test" >
|
||||
|
||||
<xsd:complexType name="TRecordSampleType" wst_record="true">
|
||||
<xsd:complexType name="TRecordSampleType" wst:wst_record="true">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<xsd:element name="TRecordSample" type="n:TRecordSampleType"/>
|
||||
|
||||
<xsd:complexType name="TRecordSampleTypeAll" wst_record="true">
|
||||
<xsd:complexType name="TRecordSampleTypeAll" wst:wst_record="true">
|
||||
<xsd:all>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
|
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:wst="urn:wst_base"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:complexType name="TRecordSampleType" wst_record="true">
|
||||
<xsd:complexType name="TRecordSampleType" wst:wst_record="true">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
<xsd:element name="TRecordSample" type="n:TRecordSampleType"/>
|
||||
|
||||
<xsd:complexType name="TRecordSampleTypeAll" wst_record="true">
|
||||
<xsd:complexType name="TRecordSampleTypeAll" wst:wst_record="true">
|
||||
<xsd:all>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
|
@@ -4,13 +4,14 @@
|
||||
xmlns:tns="library1"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:wst="urn:wst_base"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test" xmlns:n="urn:wst-test" >
|
||||
|
||||
<xsd:element name="TRecordSampleType">
|
||||
<xsd:complexType wst_record="true">
|
||||
<xsd:complexType wst:wst_record="true">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
@@ -25,7 +26,7 @@
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="TRecordSampleTypeAll">
|
||||
<xsd:complexType wst_record="true">
|
||||
<xsd:complexType wst:wst_record="true">
|
||||
<xsd:all>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
|
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:wst="urn:wst_base"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:element name="TRecordSampleType">
|
||||
<xsd:complexType wst_record="true">
|
||||
<xsd:complexType wst:wst_record="true">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
@@ -19,7 +20,7 @@
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="TRecordSampleTypeAll">
|
||||
<xsd:complexType wst_record="true">
|
||||
<xsd:complexType wst:wst_record="true">
|
||||
<xsd:all>
|
||||
<xsd:element name="intField" type="xsd:int" />
|
||||
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
|
20
wst/trunk/tests/test_suite/files/pascal_class_parent.WSDL
Normal file
20
wst/trunk/tests/test_suite/files/pascal_class_parent.WSDL
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<definitions name="wst_test"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:tns="library1"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:complexType name="TClassSample" />
|
||||
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
|
||||
</definitions>
|
8
wst/trunk/tests/test_suite/files/pascal_class_parent.xsd
Normal file
8
wst/trunk/tests/test_suite/files/pascal_class_parent.xsd
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:n="urn:wst-test"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="urn:wst-test">
|
||||
|
||||
<xsd:complexType name="TClassSample" />
|
||||
|
||||
</xsd:schema>
|
@@ -26,6 +26,8 @@ type
|
||||
|
||||
TPropertyType = ( ptField, ptAttribute );
|
||||
|
||||
{ TTest_CustomXsdGenerator }
|
||||
|
||||
TTest_CustomXsdGenerator = class(TTestCase)
|
||||
protected
|
||||
function CreateGenerator(const ADoc : TXMLDocument) : IXsdGenerator;virtual;abstract;
|
||||
@@ -33,6 +35,7 @@ type
|
||||
published
|
||||
procedure class_properties_default();
|
||||
procedure class_properties_extended_metadata();
|
||||
procedure class_extent_native_type();
|
||||
end;
|
||||
|
||||
TTest_XsdGenerator = class(TTest_CustomXsdGenerator)
|
||||
@@ -181,6 +184,76 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_CustomXsdGenerator.class_extent_native_type();
|
||||
var
|
||||
tr : TwstPasTreeContainer;
|
||||
mdl : TPasModule;
|
||||
cltyp : TPasClassType;
|
||||
|
||||
procedure AddProperty(
|
||||
const AName,
|
||||
ATypeName,
|
||||
ADefault : string;
|
||||
const AKind : TPropertyType
|
||||
);
|
||||
var
|
||||
p : TPasProperty;
|
||||
begin
|
||||
p := TPasProperty(tr.CreateElement(TPasProperty,AName,cltyp,visDefault,'',0));
|
||||
cltyp.Members.Add(p);
|
||||
p.ReadAccessorName := 'F' + AName;
|
||||
p.WriteAccessorName := 'F' + AName;
|
||||
p.VarType := tr.FindElement(ATypeName) as TPasType;
|
||||
Check( (p.VarType <> nil), Format('Type not found : "%s".',[ATypeName]));
|
||||
p.VarType.AddRef();
|
||||
p.DefaultValue := ADefault;
|
||||
p.Visibility := visPublished;
|
||||
p.StoredAccessorName := 'True';
|
||||
if ( AKind = ptAttribute ) then
|
||||
tr.SetPropertyAsAttribute(p,True);
|
||||
end;
|
||||
|
||||
var
|
||||
g : IGenerator;
|
||||
locDoc, locExistDoc : TXMLDocument;
|
||||
begin
|
||||
locDoc := nil;
|
||||
locExistDoc := nil;
|
||||
tr := TwstPasTreeContainer.Create();
|
||||
try
|
||||
CreateWstInterfaceSymbolTable(tr);
|
||||
mdl := TPasModule(tr.CreateElement(TPasModule,'class_extent_native_type',tr.Package,visDefault,'',0));
|
||||
tr.Package.Modules.Add(mdl);
|
||||
mdl.InterfaceSection := TPasSection(tr.CreateElement(TPasSection,'',mdl,visDefault,'',0));
|
||||
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TExtendString',mdl.InterfaceSection,visDefault,'',0));
|
||||
cltyp.ObjKind := okClass;
|
||||
cltyp.AncestorType := tr.FindElementNS('TComplexStringContentRemotable',sXSD_NS) as TPasType;
|
||||
cltyp.AncestorType.AddRef();
|
||||
mdl.InterfaceSection.Declarations.Add(cltyp);
|
||||
mdl.InterfaceSection.Types.Add(cltyp);
|
||||
AddProperty('intAtt','integer','',ptAttribute);
|
||||
|
||||
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TExtendBase64String',mdl.InterfaceSection,visDefault,'',0));
|
||||
cltyp.ObjKind := okClass;
|
||||
cltyp.AncestorType := tr.FindElementNS('TBase64StringExtRemotable',sXSD_NS) as TPasType;
|
||||
cltyp.AncestorType.AddRef();
|
||||
mdl.InterfaceSection.Declarations.Add(cltyp);
|
||||
mdl.InterfaceSection.Types.Add(cltyp);
|
||||
AddProperty('strAtt','string','',ptAttribute);
|
||||
|
||||
locDoc := CreateDoc();
|
||||
g := CreateGenerator(locDoc);
|
||||
g.Execute(tr,mdl.Name);
|
||||
WriteXMLFile(locDoc,'.\class_extent_native_type.xsd');
|
||||
locExistDoc := LoadXmlFromFilesList('class_extent_native_type.xsd');
|
||||
Check(CompareNodes(locExistDoc,locDoc),'generated document differs from the existent one.');
|
||||
finally
|
||||
ReleaseDomNode(locExistDoc);
|
||||
ReleaseDomNode(locDoc);
|
||||
FreeAndNil(tr);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TTest_CustomXsdGenerator.LoadXmlFromFilesList(const AFileName: string): TXMLDocument;
|
||||
var
|
||||
locFileName : string;
|
||||
|
@@ -45,6 +45,10 @@ type
|
||||
|
||||
function LoadComplexType_ArraySequence_Schema() : TwstPasTreeContainer;virtual;abstract;
|
||||
function LoadComplexType_ArraySequence_Embedded_Schema() : TwstPasTreeContainer;virtual;abstract;
|
||||
|
||||
function LoadComplexType_CollectionSequence_Schema() : TwstPasTreeContainer;virtual;abstract;
|
||||
|
||||
function LoadComplexType_pascal_class_parent() : TwstPasTreeContainer;virtual;abstract;
|
||||
published
|
||||
procedure EmptySchema();
|
||||
|
||||
@@ -63,6 +67,9 @@ type
|
||||
|
||||
procedure ComplexType_ArraySequence();
|
||||
procedure ComplexType_ArraySequence_Embedded();
|
||||
|
||||
procedure ComplexType_CollectionSequence();
|
||||
procedure pascal_class_default_parent();
|
||||
end;
|
||||
|
||||
{ TTest_XsdParser }
|
||||
@@ -88,6 +95,10 @@ type
|
||||
|
||||
function LoadComplexType_ArraySequence_Schema() : TwstPasTreeContainer;override;
|
||||
function LoadComplexType_ArraySequence_Embedded_Schema() : TwstPasTreeContainer;override;
|
||||
|
||||
function LoadComplexType_CollectionSequence_Schema() : TwstPasTreeContainer;override;
|
||||
|
||||
function LoadComplexType_pascal_class_parent() : TwstPasTreeContainer;override;
|
||||
end;
|
||||
|
||||
{ TTest_WsdlParser }
|
||||
@@ -113,6 +124,10 @@ type
|
||||
|
||||
function LoadComplexType_ArraySequence_Schema() : TwstPasTreeContainer;override;
|
||||
function LoadComplexType_ArraySequence_Embedded_Schema() : TwstPasTreeContainer;override;
|
||||
|
||||
function LoadComplexType_CollectionSequence_Schema() : TwstPasTreeContainer;override;
|
||||
|
||||
function LoadComplexType_pascal_class_parent() : TwstPasTreeContainer;override;
|
||||
published
|
||||
procedure no_binding_style();
|
||||
end;
|
||||
@@ -123,6 +138,11 @@ uses parserutils;
|
||||
const
|
||||
x_complexType_SampleArrayIntFieldType = 'TArrayIntFieldType';
|
||||
x_complexType_SampleArrayItemType = 'TArrayItemType';
|
||||
|
||||
x_complexType_SampleCollectionComplexType = 'TComplexType';
|
||||
x_complexType_SampleCollectionCollectionComplexType = 'TCollectionComplexType';
|
||||
x_complexType_SampleCollectionItemType = 'TCollectionItemType';
|
||||
|
||||
x_complexType_SampleDerivedType = 'TClassSampleDerivedType';
|
||||
x_complexType_SampleClassType = 'TClassSampleType';
|
||||
x_complexType_SampleClassTypeA = 'TClassSampleTypeA';
|
||||
@@ -135,6 +155,8 @@ const
|
||||
|
||||
x_complexType_array_sequence = 'complex_array_sequence';
|
||||
x_complexType_array_sequence_embedded = 'complex_array_sequence_embedded';
|
||||
x_complexType_array_sequence_collection = 'complex_array_sequence_collection';
|
||||
|
||||
x_complexType_class = 'complex_class';
|
||||
x_complexType_class_default = 'complex_class_default';
|
||||
x_complexType_class_properties_extended_metadata = 'class_properties_extended_metadata';
|
||||
@@ -162,6 +184,7 @@ const
|
||||
x_charField = 'charField';
|
||||
x_classField = 'classField';
|
||||
x_enumField = 'enumField';
|
||||
x_field = 'field';
|
||||
x_floatField = 'floatField';
|
||||
x_intField = 'intField';
|
||||
x_longField = 'longField';
|
||||
@@ -586,6 +609,7 @@ var
|
||||
i : Integer;
|
||||
prpLs : TList;
|
||||
begin
|
||||
tr := nil;
|
||||
prpLs := TList.Create();
|
||||
try
|
||||
tr := LoadComplexType_Class_Extend_Simple_Schema();
|
||||
@@ -602,6 +626,9 @@ begin
|
||||
CheckEquals(x_complexType_SampleClassType,tr.GetExternalName(elt));
|
||||
CheckIs(elt,TPasClassType);
|
||||
clsType := elt as TPasClassType;
|
||||
CheckNotNull(clsType.AncestorType,'AncestorType is null');
|
||||
CheckSame(tr.FindElementNS('TComplexStringContentRemotable',sXSD_NS),clsType.AncestorType);
|
||||
|
||||
prpLs.Clear();
|
||||
for i := 0 to Pred(clsType.Members.Count) do begin
|
||||
if TPasElement(clsType.Members[i]).InheritsFrom(TPasProperty) then
|
||||
@@ -617,6 +644,9 @@ begin
|
||||
CheckEquals(x_complexType_SampleClassTypeA,tr.GetExternalName(elt));
|
||||
CheckIs(elt,TPasClassType);
|
||||
clsType := elt as TPasClassType;
|
||||
CheckNotNull(clsType.AncestorType,'AncestorType is null');
|
||||
CheckSame(tr.FindElementNS('TBase64StringExtRemotable',sXSD_NS),clsType.AncestorType);
|
||||
|
||||
prpLs.Clear();
|
||||
for i := 0 to Pred(clsType.Members.Count) do begin
|
||||
if TPasElement(clsType.Members[i]).InheritsFrom(TPasProperty) then
|
||||
@@ -625,6 +655,7 @@ begin
|
||||
CheckEquals(1,prpLs.Count);
|
||||
CheckProperty(x_floatField,'float',ptAttribute);
|
||||
finally
|
||||
tr.Free();
|
||||
FreeAndNil(prpLs);
|
||||
end;
|
||||
end;
|
||||
@@ -982,7 +1013,121 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_CustomXsdParser.ComplexType_Class_default_values;
|
||||
procedure TTest_CustomXsdParser.ComplexType_CollectionSequence();
|
||||
var
|
||||
tr : TwstPasTreeContainer;
|
||||
clsType : TPasClassType;
|
||||
|
||||
procedure CheckProperty(const AName,ATypeName : string; const AFieldType : TPropertyType);
|
||||
var
|
||||
prp : TPasProperty;
|
||||
begin
|
||||
prp := FindMember(clsType,AName) as TPasProperty;
|
||||
CheckNotNull(prp);
|
||||
CheckEquals(AName,prp.Name);
|
||||
CheckEquals(AName,tr.GetExternalName(prp));
|
||||
CheckNotNull(prp.VarType);
|
||||
CheckEquals(ATypeName,tr.GetExternalName(prp.VarType));
|
||||
CheckEquals(PropertyType_Att[AFieldType],tr.IsAttributeProperty(prp));
|
||||
end;
|
||||
|
||||
var
|
||||
mdl : TPasModule;
|
||||
ls : TList;
|
||||
elt : TPasElement;
|
||||
arrayType : TPasArrayType;
|
||||
aliasType : TPasAliasType;
|
||||
i : Integer;
|
||||
prpLs : TList;
|
||||
nestedClassName : string;
|
||||
begin
|
||||
prpLs := TList.Create();
|
||||
try
|
||||
tr := LoadComplexType_CollectionSequence_Schema();
|
||||
|
||||
mdl := tr.FindModule(x_targetNamespace);
|
||||
CheckNotNull(mdl);
|
||||
CheckEquals(x_complexType_array_sequence_collection,mdl.Name);
|
||||
CheckEquals(x_targetNamespace,tr.GetExternalName(mdl));
|
||||
ls := mdl.InterfaceSection.Declarations;
|
||||
CheckEquals(4,ls.Count);
|
||||
elt := tr.FindElement(x_complexType_SampleCollectionCollectionComplexType);
|
||||
CheckNotNull(elt,x_complexType_SampleCollectionCollectionComplexType);
|
||||
CheckEquals(x_complexType_SampleCollectionCollectionComplexType,elt.Name);
|
||||
CheckEquals(x_complexType_SampleCollectionCollectionComplexType,tr.GetExternalName(elt));
|
||||
CheckIs(elt,TPasArrayType);
|
||||
arrayType := elt as TPasArrayType;
|
||||
Check(tr.IsCollection(arrayType));
|
||||
CheckNotNull(arrayType.ElType);
|
||||
CheckEquals(x_complexType_SampleCollectionComplexType,tr.GetExternalName(arrayType.ElType));
|
||||
CheckEquals(x_field,tr.GetArrayItemName(arrayType));
|
||||
CheckEquals(x_field,tr.GetArrayItemExternalName(arrayType));
|
||||
|
||||
|
||||
nestedClassName := Format('%s_%s_Type',[x_complexType_SampleCollectionItemType,x_Item]);
|
||||
elt := tr.FindElement(nestedClassName);
|
||||
CheckNotNull(elt,nestedClassName);
|
||||
CheckEquals(nestedClassName,elt.Name,'Item Name');
|
||||
CheckEquals(nestedClassName,tr.GetExternalName(elt),'Item ExternalName');
|
||||
CheckIs(elt,TPasClassType);
|
||||
clsType := elt as TPasClassType;
|
||||
|
||||
prpLs.Clear();
|
||||
for i := 0 to Pred(clsType.Members.Count) do begin
|
||||
if TPasElement(clsType.Members[i]).InheritsFrom(TPasProperty) then
|
||||
prpLs.Add(clsType.Members[i]);
|
||||
end;
|
||||
CheckEquals(8,prpLs.Count);
|
||||
CheckProperty(x_intField,'int',ptField);
|
||||
CheckProperty(x_strField,'string',ptField);
|
||||
CheckProperty(x_floatField,'float',ptField);
|
||||
CheckProperty(x_byteField,'byte',ptField);
|
||||
CheckProperty(x_charField,'char',ptField);
|
||||
CheckProperty(x_longField,'long',ptField);
|
||||
CheckProperty(x_strAtt,'string',ptAttribute);
|
||||
CheckProperty(x_intAtt,'int',ptAttribute);
|
||||
|
||||
elt := tr.FindElement(x_complexType_SampleCollectionItemType);
|
||||
CheckNotNull(elt,x_complexType_SampleCollectionItemType);
|
||||
CheckEquals(x_complexType_SampleCollectionItemType,elt.Name, 'Array name');
|
||||
CheckEquals(x_complexType_SampleCollectionItemType,tr.GetExternalName(elt), 'Array external name');
|
||||
CheckIs(elt,TPasArrayType);
|
||||
arrayType := elt as TPasArrayType;
|
||||
Check(tr.IsCollection(arrayType));
|
||||
CheckNotNull(arrayType.ElType);
|
||||
CheckEquals(nestedClassName,tr.GetExternalName(arrayType.ElType));
|
||||
CheckEquals(x_Item,tr.GetArrayItemExternalName(arrayType));
|
||||
|
||||
finally
|
||||
FreeAndNil(prpLs);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_CustomXsdParser.pascal_class_default_parent();
|
||||
var
|
||||
tr : TwstPasTreeContainer;
|
||||
mdl : TPasModule;
|
||||
clsType : TPasClassType;
|
||||
elt : TPasElement;
|
||||
begin
|
||||
tr := LoadComplexType_pascal_class_parent();
|
||||
try
|
||||
mdl := tr.FindModule(x_targetNamespace);
|
||||
CheckNotNull(mdl);
|
||||
elt := tr.FindElement(x_complexType_SampleClass);
|
||||
CheckNotNull(elt,x_complexType_SampleClass);
|
||||
CheckEquals(x_complexType_SampleClass,elt.Name);
|
||||
CheckEquals(x_complexType_SampleClass,tr.GetExternalName(elt));
|
||||
CheckIs(elt,TPasClassType);
|
||||
clsType := elt as TPasClassType;
|
||||
CheckNotNull(clsType.AncestorType,'AncestorType is null');
|
||||
CheckSame(tr.FindElementNS('TBaseComplexRemotable',sXSD_NS),clsType.AncestorType);
|
||||
finally
|
||||
tr.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_CustomXsdParser.ComplexType_Class_default_values();
|
||||
var
|
||||
tr : TwstPasTreeContainer;
|
||||
clsType : TPasClassType;
|
||||
@@ -1198,6 +1343,16 @@ begin
|
||||
Result := ParseDoc(x_complexType_array_sequence_embedded);
|
||||
end;
|
||||
|
||||
function TTest_XsdParser.LoadComplexType_CollectionSequence_Schema() : TwstPasTreeContainer;
|
||||
begin
|
||||
Result := ParseDoc(x_complexType_array_sequence_collection);
|
||||
end;
|
||||
|
||||
function TTest_XsdParser.LoadComplexType_pascal_class_parent() : TwstPasTreeContainer;
|
||||
begin
|
||||
Result := ParseDoc('pascal_class_parent');
|
||||
end;
|
||||
|
||||
function TTest_XsdParser.LoadComplexType_Class_default_values() : TwstPasTreeContainer;
|
||||
begin
|
||||
Result := ParseDoc(x_complexType_class_default);
|
||||
@@ -1286,6 +1441,16 @@ begin
|
||||
Result := ParseDoc(x_complexType_array_sequence_embedded);
|
||||
end;
|
||||
|
||||
function TTest_WsdlParser.LoadComplexType_CollectionSequence_Schema() : TwstPasTreeContainer;
|
||||
begin
|
||||
Result := ParseDoc(x_complexType_array_sequence_collection);
|
||||
end;
|
||||
|
||||
function TTest_WsdlParser.LoadComplexType_pascal_class_parent() : TwstPasTreeContainer;
|
||||
begin
|
||||
Result := ParseDoc('pascal_class_parent');
|
||||
end;
|
||||
|
||||
procedure TTest_WsdlParser.no_binding_style();
|
||||
var
|
||||
symTable : TwstPasTreeContainer;
|
||||
|
@@ -52,7 +52,7 @@ type
|
||||
property BoolProp : Boolean read FBoolProp write FBoolProp;
|
||||
end;
|
||||
TClass_AClass = class of TClass_A;
|
||||
|
||||
|
||||
{ TRttiExpIntegerNodeItem_Test }
|
||||
|
||||
TRttiExpIntegerNodeItem_Test = class(TTestCase)
|
||||
@@ -60,7 +60,9 @@ type
|
||||
procedure Create_Test();
|
||||
procedure Evaluate_Equal();
|
||||
procedure Evaluate_Lesser();
|
||||
procedure Evaluate_LesserOrEqual();
|
||||
procedure Evaluate_Greater();
|
||||
procedure Evaluate_GreaterOrEqual();
|
||||
end;
|
||||
|
||||
{ TRttiExpEnumNodeItem_Test }
|
||||
@@ -71,7 +73,9 @@ type
|
||||
procedure Evaluate_Equal();
|
||||
procedure Evaluate_Equal_bool();
|
||||
procedure Evaluate_Lesser();
|
||||
procedure Evaluate_LesserOrEqual();
|
||||
procedure Evaluate_Greater();
|
||||
procedure Evaluate_GreaterOrEqual();
|
||||
end;
|
||||
|
||||
{ TRttiExpAnsiStringNodeItem_Test }
|
||||
@@ -203,6 +207,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpIntegerNodeItem_Test.Evaluate_LesserOrEqual();
|
||||
const VAL_1 : Integer = 1210;
|
||||
var
|
||||
x : TRttiExpIntegerNodeItem;
|
||||
t : TClass_A;
|
||||
begin
|
||||
x := nil;
|
||||
t := TClass_A.Create();
|
||||
try
|
||||
x := TRttiExpIntegerNodeItem.Create(GetPropInfo(t,'IntProp'),nfoLesserOrEqual,VAL_1);
|
||||
|
||||
t.IntProp := 0;
|
||||
Check( x.Evaluate(t) = True ,'True');
|
||||
|
||||
t.IntProp := -VAL_1;
|
||||
Check( x.Evaluate(t) = True ,'True');
|
||||
|
||||
t.IntProp := VAL_1 + 1;
|
||||
Check( x.Evaluate(t) = False, 'False' );
|
||||
finally
|
||||
x.Free();
|
||||
t.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpIntegerNodeItem_Test.Evaluate_Greater();
|
||||
const VAL_1 : Integer = 1210;
|
||||
var
|
||||
@@ -225,6 +254,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpIntegerNodeItem_Test.Evaluate_GreaterOrEqual();
|
||||
const VAL_1 : Integer = 1210;
|
||||
var
|
||||
x : TRttiExpIntegerNodeItem;
|
||||
t : TClass_A;
|
||||
begin
|
||||
x := nil;
|
||||
t := TClass_A.Create();
|
||||
try
|
||||
x := TRttiExpIntegerNodeItem.Create(GetPropInfo(t,'IntProp'),nfoGreaterOrEqual,VAL_1);
|
||||
|
||||
t.IntProp := 0;
|
||||
Check( x.Evaluate(t) = False, 'False' );
|
||||
|
||||
t.IntProp := VAL_1;
|
||||
Check( x.Evaluate(t) = True ,'True');
|
||||
|
||||
t.IntProp := VAL_1 + 1;
|
||||
Check( x.Evaluate(t) = True ,'True');
|
||||
finally
|
||||
x.Free();
|
||||
t.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TRttiExpNode_Test }
|
||||
|
||||
@@ -1250,6 +1304,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpEnumNodeItem_Test.Evaluate_LesserOrEqual();
|
||||
const VAL_1 : TSampleEnum = SampleEnum_C;
|
||||
var
|
||||
x : TRttiExpEnumNodeItem;
|
||||
t : TClass_A;
|
||||
begin
|
||||
x := nil;
|
||||
t := TClass_A.Create();
|
||||
try
|
||||
x := TRttiExpEnumNodeItem.Create(GetPropInfo(t,'EnumProp'),nfoLesserOrEqual,GetEnumName(TypeInfo(TSampleEnum),Ord(VAL_1)));
|
||||
|
||||
t.EnumProp := SampleEnum_D;
|
||||
Check( x.Evaluate(t) = False ,'False');
|
||||
|
||||
t.EnumProp := SampleEnum_B;
|
||||
Check( x.Evaluate(t) = True, 'True' );
|
||||
|
||||
t.EnumProp := VAL_1;
|
||||
Check( x.Evaluate(t) = True, 'True' );
|
||||
finally
|
||||
x.Free();
|
||||
t.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpEnumNodeItem_Test.Evaluate_Greater();
|
||||
const VAL_1 : TSampleEnum = SampleEnum_C;
|
||||
var
|
||||
@@ -1272,6 +1351,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRttiExpEnumNodeItem_Test.Evaluate_GreaterOrEqual();
|
||||
const VAL_1 : TSampleEnum = SampleEnum_C;
|
||||
var
|
||||
x : TRttiExpEnumNodeItem;
|
||||
t : TClass_A;
|
||||
begin
|
||||
x := nil;
|
||||
t := TClass_A.Create();
|
||||
try
|
||||
x := TRttiExpEnumNodeItem.Create(GetPropInfo(t,'EnumProp'),nfoGreaterOrEqual,GetEnumName(TypeInfo(TSampleEnum),Ord(VAL_1)));
|
||||
|
||||
t.EnumProp := SampleEnum_A;
|
||||
Check( x.Evaluate(t) = False ,'False');
|
||||
|
||||
t.EnumProp := SampleEnum_D;
|
||||
Check( x.Evaluate(t) = True, 'True' );
|
||||
|
||||
t.EnumProp := VAL_1;
|
||||
Check( x.Evaluate(t) = True, 'True' );
|
||||
finally
|
||||
x.Free();
|
||||
t.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
Initialization
|
||||
RegisterTest('Cursors',TRttiExpIntegerNodeItem_Test.Suite);
|
||||
RegisterTest('Cursors',TRttiExpEnumNodeItem_Test.Suite);
|
||||
|
@@ -351,6 +351,31 @@ type
|
||||
procedure SetEncodedString();
|
||||
end;
|
||||
|
||||
{ TClass_A_CollectionRemotable }
|
||||
|
||||
TClass_A_CollectionRemotable = class(TObjectCollectionRemotable)
|
||||
private
|
||||
function GetItem(AIndex : PtrInt) : TClass_A;
|
||||
public
|
||||
class function GetItemClass():TBaseRemotableClass;override;
|
||||
function Add(): TClass_A;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||
function AddAt(const APosition : PtrInt): TClass_A;{$IFDEF USE_INLINE}inline;{$ENDIF}
|
||||
property Item[AIndex:PtrInt] : TClass_A read GetItem;default;
|
||||
end;
|
||||
|
||||
{ TTest_TObjectCollectionRemotable }
|
||||
|
||||
TTest_TObjectCollectionRemotable = class(TTestCase)
|
||||
published
|
||||
procedure GetItemTypeInfo();
|
||||
procedure Add();
|
||||
procedure Delete();
|
||||
procedure Equal();
|
||||
procedure test_Assign();
|
||||
procedure Exchange();
|
||||
procedure IndexOf();
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses Math, basex_encode;
|
||||
|
||||
@@ -2541,7 +2566,235 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TClass_A_CollectionRemotable }
|
||||
|
||||
function TClass_A_CollectionRemotable.GetItem(AIndex : PtrInt) : TClass_A;
|
||||
begin
|
||||
Result := TClass_A(inherited Item[AIndex]);
|
||||
end;
|
||||
|
||||
class function TClass_A_CollectionRemotable.GetItemClass() : TBaseRemotableClass;
|
||||
begin
|
||||
Result := TClass_A;
|
||||
end;
|
||||
|
||||
function TClass_A_CollectionRemotable.Add() : TClass_A;
|
||||
begin
|
||||
Result := TClass_A(inherited Add());
|
||||
end;
|
||||
|
||||
function TClass_A_CollectionRemotable.AddAt(const APosition : PtrInt) : TClass_A;
|
||||
begin
|
||||
Result := TClass_A(inherited AddAt(APosition));
|
||||
end;
|
||||
|
||||
{ TTest_TObjectCollectionRemotable }
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.GetItemTypeInfo();
|
||||
begin
|
||||
CheckEquals(
|
||||
PtrUInt(TClass_A_CollectionRemotable.GetItemClass().ClassInfo),
|
||||
PtrUInt(TClass_A_CollectionRemotable.GetItemTypeInfo())
|
||||
);
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.Add();
|
||||
var
|
||||
ls : TClass_A_CollectionRemotable;
|
||||
aa,ab : TClass_A;
|
||||
begin
|
||||
ls := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
aa := ls.Add();
|
||||
CheckNotNull(aa);
|
||||
CheckEquals(1,ls.Length);
|
||||
CheckSame(aa, ls[0]);
|
||||
ab := ls.Add();
|
||||
CheckNotNull(ab);
|
||||
CheckEquals(2,ls.Length);
|
||||
CheckSame(ab, ls[1]);
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.Delete();
|
||||
var
|
||||
ls : TClass_A_CollectionRemotable;
|
||||
aa,ab : TClass_A;
|
||||
ok : Boolean;
|
||||
begin
|
||||
ls := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
ok := False;
|
||||
try
|
||||
ls.Delete(-112);
|
||||
except
|
||||
ok := True;
|
||||
end;
|
||||
Check(ok);
|
||||
|
||||
ok := False;
|
||||
try
|
||||
ls.Delete(0);
|
||||
except
|
||||
ok := True;
|
||||
end;
|
||||
Check(ok);
|
||||
|
||||
ok := False;
|
||||
try
|
||||
ls.Delete(112);
|
||||
except
|
||||
ok := True;
|
||||
end;
|
||||
Check(ok);
|
||||
|
||||
aa := ls.Add();
|
||||
ls.Delete(0);
|
||||
CheckEquals(0,ls.Length);
|
||||
|
||||
aa := ls.Add();
|
||||
ab := ls.Add();
|
||||
ls.Delete(0);
|
||||
CheckEquals(1,ls.Length);
|
||||
CheckSame(ab,ls[0]);
|
||||
|
||||
FreeAndNil(ls);
|
||||
ls := TClass_A_CollectionRemotable.Create();
|
||||
aa := ls.Add();
|
||||
ab := ls.Add();
|
||||
ls.Delete(1);
|
||||
CheckEquals(1,ls.Length);
|
||||
CheckSame(aa,ls[0]);
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.Equal();
|
||||
var
|
||||
a, b : TClass_A_CollectionRemotable;
|
||||
begin
|
||||
b := nil;
|
||||
a := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
b := TClass_A_CollectionRemotable.Create();
|
||||
Check(a.Equal(b));
|
||||
Check(b.Equal(a));
|
||||
a.Add().Val_16S := 1;
|
||||
a.Add().Val_16S := 2;
|
||||
Check(not a.Equal(nil));
|
||||
Check(a.Equal(a));
|
||||
Check(not a.Equal(b));
|
||||
Check(not b.Equal(a));
|
||||
|
||||
b.Add().Val_16S := 1;
|
||||
Check(not a.Equal(b));
|
||||
Check(not b.Equal(a));
|
||||
b.Add().Val_16S := 2;
|
||||
Check(a.Equal(b));
|
||||
Check(b.Equal(a));
|
||||
finally
|
||||
b.Free();
|
||||
a.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.test_Assign();
|
||||
|
||||
procedure Check_List(Aa, Ab : TClass_A_CollectionRemotable);
|
||||
var
|
||||
k : PtrInt;
|
||||
begin
|
||||
if ( Aa = nil ) then begin
|
||||
CheckNull(Ab);
|
||||
end else begin
|
||||
CheckNotNull(Ab);
|
||||
CheckEquals(Aa.Length,Ab.Length);
|
||||
if ( Aa.Length > 0 ) then begin
|
||||
for k := 0 to Pred(Aa.Length) do begin
|
||||
Check(Aa[k].Equal(Ab[k]));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
a, b : TClass_A_CollectionRemotable;
|
||||
begin
|
||||
b := nil;
|
||||
a := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
b := TClass_A_CollectionRemotable.Create();
|
||||
Check_List(a,b);
|
||||
a.Add().Val_16S := 1;
|
||||
a.Add().Val_16S := 2;
|
||||
b.Assign(a);
|
||||
Check_List(a,b);
|
||||
|
||||
b.Add().Val_16S := 3;
|
||||
a.Assign(b);
|
||||
Check_List(a,b);
|
||||
|
||||
a.Clear();
|
||||
b.Assign(a);
|
||||
Check_List(a,b);
|
||||
finally
|
||||
b.Free();
|
||||
a.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.Exchange();
|
||||
var
|
||||
ls : TClass_A_CollectionRemotable;
|
||||
a, b, c : TClass_A;
|
||||
begin
|
||||
ls := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
a := ls.Add();
|
||||
ls.Exchange(0,0);
|
||||
CheckSame(a,ls[0]);
|
||||
b := ls.Add();
|
||||
ls.Exchange(0,1);
|
||||
CheckSame(a,ls[1]);
|
||||
CheckSame(b,ls[0]);
|
||||
c := ls.Add();
|
||||
ls.Exchange(0,2);
|
||||
CheckSame(c,ls[0]);
|
||||
CheckSame(b,ls[2]);
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest_TObjectCollectionRemotable.IndexOf();
|
||||
var
|
||||
ls : TClass_A_CollectionRemotable;
|
||||
begin
|
||||
ls := TClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
CheckEquals(-1, ls.IndexOf(nil));
|
||||
ls.Add();
|
||||
CheckEquals(-1, ls.IndexOf(nil));
|
||||
CheckEquals(0, ls.IndexOf(ls[0]));
|
||||
ls.Add();
|
||||
CheckEquals(-1, ls.IndexOf(nil));
|
||||
CheckEquals(0, ls.IndexOf(ls[0]));
|
||||
CheckEquals(1, ls.IndexOf(ls[1]));
|
||||
ls.Add();
|
||||
CheckEquals(-1, ls.IndexOf(nil));
|
||||
CheckEquals(0, ls.IndexOf(ls[0]));
|
||||
CheckEquals(1, ls.IndexOf(ls[1]));
|
||||
CheckEquals(2, ls.IndexOf(ls[2]));
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTest('Support',TTest_TObjectCollectionRemotable.Suite);
|
||||
RegisterTest('Support',TTest_TBaseComplexRemotable.Suite);
|
||||
RegisterTest('Support',TTest_TStringBufferRemotable.Suite);
|
||||
RegisterTest('Support-Date',TTest_TDateRemotable.Suite);
|
||||
|
@@ -34,6 +34,13 @@ type
|
||||
public
|
||||
class function GetItemClass():TBaseRemotableClass;override;
|
||||
end;
|
||||
|
||||
{ TTClass_A_CollectionRemotable }
|
||||
|
||||
TTClass_A_CollectionRemotable = class(TObjectCollectionRemotable)
|
||||
public
|
||||
class function GetItemClass():TBaseRemotableClass;override;
|
||||
end;
|
||||
|
||||
{ TClass_B }
|
||||
|
||||
@@ -69,12 +76,21 @@ type
|
||||
procedure All();
|
||||
end;
|
||||
|
||||
{ TObjectCollectionRemotableCursor_Test }
|
||||
|
||||
TObjectCollectionRemotableCursor_Test = class(TTestCase)
|
||||
published
|
||||
procedure All();
|
||||
end;
|
||||
|
||||
{ TUtilsProcs_Test }
|
||||
|
||||
TUtilsProcs_Test = class(TTestCase)
|
||||
published
|
||||
procedure test_Find();
|
||||
procedure test_Filter();
|
||||
procedure test_Find_array();
|
||||
procedure test_Find_collection();
|
||||
procedure test_Filter_array();
|
||||
procedure test_Filter_collection();
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -277,7 +293,7 @@ end;
|
||||
|
||||
{ TUtilsProcs_Test }
|
||||
|
||||
procedure TUtilsProcs_Test.test_Find();
|
||||
procedure TUtilsProcs_Test.test_Find_array();
|
||||
const O_COUNT : PtrInt = 10;
|
||||
var
|
||||
ls : TTClass_A_ArrayRemotable;
|
||||
@@ -306,14 +322,43 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUtilsProcs_Test.test_Filter();
|
||||
procedure TUtilsProcs_Test.test_Find_collection();
|
||||
const O_COUNT : PtrInt = 10;
|
||||
var
|
||||
ls : TTClass_A_CollectionRemotable;
|
||||
i : PtrInt;
|
||||
begin
|
||||
ls := TTClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
CheckNull(Find(ls,''));
|
||||
CheckNull(Find(ls,'IntProp = 12'));
|
||||
|
||||
ls.Add();
|
||||
CheckSame(ls[0], Find(ls,''));
|
||||
CheckSame(ls[0], Find(ls,'IntProp = 0'));
|
||||
CheckNull(Find(ls,'IntProp = 12'));
|
||||
|
||||
ls.Clear();
|
||||
for i := 0 to ( O_COUNT - 1 ) do
|
||||
TClass_A(ls.Add()).FIntProp := i;
|
||||
CheckSame(ls[0], Find(ls,''));
|
||||
CheckSame(ls[0], Find(ls,'IntProp = 0'));
|
||||
CheckNull(Find(ls,Format('IntProp = %d',[2*O_COUNT])));
|
||||
for i := 0 to ( O_COUNT - 1 ) do
|
||||
CheckSame(ls[i],Find(ls,Format('IntProp = %d',[i])));
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUtilsProcs_Test.test_Filter_array();
|
||||
const O_COUNT : PtrInt = 10;
|
||||
var
|
||||
ls : TTClass_A_ArrayRemotable;
|
||||
i : PtrInt;
|
||||
crs : IObjectCursor;
|
||||
begin
|
||||
CheckNull(Filter(nil,''), 'filter(nil) = nil');
|
||||
CheckNull(Filter(TTClass_A_ArrayRemotable(nil),''), 'filter(nil) = nil');
|
||||
ls := TTClass_A_ArrayRemotable.Create();
|
||||
try
|
||||
crs := Filter(ls,'');
|
||||
@@ -346,9 +391,120 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUtilsProcs_Test.test_Filter_collection();
|
||||
const O_COUNT : PtrInt = 10;
|
||||
var
|
||||
ls : TTClass_A_CollectionRemotable;
|
||||
i : PtrInt;
|
||||
crs : IObjectCursor;
|
||||
begin
|
||||
CheckNull(Filter(TTClass_A_CollectionRemotable(nil),''), 'filter(nil) = nil');
|
||||
ls := TTClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
crs := Filter(ls,'');
|
||||
Check( ( crs <> nil ) );
|
||||
crs.Reset();
|
||||
Check(not crs.MoveNext());
|
||||
|
||||
ls.Clear();
|
||||
for i := 0 to ( O_COUNT - 1 ) do
|
||||
TClass_A(ls.Add()).FIntProp := i;
|
||||
crs := Filter(ls,'');
|
||||
Check( ( crs <> nil ) );
|
||||
crs.Reset();
|
||||
for i := 0 to ( O_COUNT - 1 ) do begin
|
||||
Check(crs.MoveNext());
|
||||
CheckSame(ls[i], crs.GetCurrent());
|
||||
end;
|
||||
Check(not crs.MoveNext());
|
||||
|
||||
for i := 0 to ( O_COUNT - 1 ) do begin
|
||||
crs := Filter(ls,Format('IntProp = %d',[i]));
|
||||
Check( ( crs <> nil ) );
|
||||
crs.Reset();
|
||||
Check(crs.MoveNext());
|
||||
CheckSame(ls[i], crs.GetCurrent());
|
||||
Check(not crs.MoveNext());
|
||||
end;
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TTClass_A_CollectionRemotable }
|
||||
|
||||
class function TTClass_A_CollectionRemotable.GetItemClass() : TBaseRemotableClass;
|
||||
begin
|
||||
Result := TClass_A;
|
||||
end;
|
||||
|
||||
{ TObjectCollectionRemotableCursor_Test }
|
||||
|
||||
procedure TObjectCollectionRemotableCursor_Test.All();
|
||||
const O_COUNT = 100;
|
||||
var
|
||||
x : IObjectCursor;
|
||||
ls : TObjectCollectionRemotable;
|
||||
c, i : PtrInt;
|
||||
begin
|
||||
ls := TTClass_A_CollectionRemotable.Create();
|
||||
try
|
||||
x := TObjectCollectionRemotableCursor.Create(ls);
|
||||
x.Reset();
|
||||
CheckEquals(False,x.MoveNext());
|
||||
x.Reset();
|
||||
CheckEquals(False,x.MoveNext());
|
||||
CheckEquals(False,x.MoveNext());
|
||||
try
|
||||
x.GetCurrent();
|
||||
Check(False);
|
||||
except
|
||||
on e : ECursorException do begin
|
||||
// GOOD
|
||||
end;
|
||||
end;
|
||||
|
||||
ls.Add();
|
||||
x.Reset();
|
||||
CheckEquals(True,x.MoveNext());
|
||||
CheckSame(ls[0],x.GetCurrent());
|
||||
CheckEquals(False,x.MoveNext());
|
||||
try
|
||||
x.GetCurrent();
|
||||
Check(False);
|
||||
except
|
||||
on e : ECursorException do begin
|
||||
// GOOD
|
||||
end;
|
||||
end;
|
||||
x.Reset();
|
||||
CheckEquals(True,x.MoveNext());
|
||||
CheckSame(ls[0],x.GetCurrent());
|
||||
CheckEquals(False,x.MoveNext());
|
||||
|
||||
ls.Clear();
|
||||
for i := 0 to Pred(O_COUNT) do
|
||||
TClass_A(ls.Add()).FIntProp := i;
|
||||
x.Reset();
|
||||
for i := 0 to Pred(O_COUNT) do begin
|
||||
CheckEquals(True,x.MoveNext());
|
||||
CheckSame(ls[i],x.GetCurrent());
|
||||
end;
|
||||
CheckEquals(False,x.MoveNext());
|
||||
x.Reset();
|
||||
for i := 0 to Pred(O_COUNT) do begin
|
||||
CheckEquals(True,x.MoveNext());
|
||||
CheckSame(ls[i],x.GetCurrent());
|
||||
end;
|
||||
finally
|
||||
ls.Free();
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTest('Cursors',TBaseObjectArrayRemotableCursor_Test.Suite);
|
||||
RegisterTest('Cursors',TBaseObjectArrayRemotableFilterableCursor_Test.Suite);
|
||||
RegisterTest('Cursors',TObjectCollectionRemotableCursor_Test.Suite);
|
||||
RegisterTest('Cursors',TUtilsProcs_Test.Suite);
|
||||
|
||||
end.
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<PackageName Value="FPCUnitTestRunner"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="35">
|
||||
<Units Count="38">
|
||||
<Unit0>
|
||||
<Filename Value="wst_test_suite.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@@ -202,6 +202,21 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_suite_utils"/>
|
||||
</Unit34>
|
||||
<Unit35>
|
||||
<Filename Value="test_std_cursors.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_std_cursors"/>
|
||||
</Unit35>
|
||||
<Unit36>
|
||||
<Filename Value="test_rtti_filter.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_rtti_filter"/>
|
||||
</Unit36>
|
||||
<Unit37>
|
||||
<Filename Value="test_wst_cursors.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_wst_cursors"/>
|
||||
</Unit37>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@@ -1,7 +1,6 @@
|
||||
{$INCLUDE wst_global.inc}
|
||||
program wst_test_suite;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$DEFINE UseCThreads}
|
||||
|
||||
uses
|
||||
@@ -19,7 +18,8 @@ uses
|
||||
server_service_xmlrpc, test_parsers, wsdl_generator, xsd_generator,
|
||||
xsd_consts, base_json_formatter, wsdl_parser, test_support, basex_encode,
|
||||
test_basex_encode, json_formatter, server_service_json, test_json,
|
||||
test_suite_utils, test_generators;
|
||||
test_suite_utils, test_generators, test_std_cursors, test_rtti_filter,
|
||||
test_wst_cursors;
|
||||
|
||||
Const
|
||||
ShortOpts = 'alh';
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<PackageName Value="fpcunittestrunner"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="10">
|
||||
<Units Count="16">
|
||||
<Unit0>
|
||||
<Filename Value="wst_test_suite_gui.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@@ -85,6 +85,36 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_suite_utils"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="test_std_cursors.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_std_cursors"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="test_rtti_filter.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_rtti_filter"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="..\..\wst_rtti_filter\rtti_filters.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="rtti_filters"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\wst_rtti_filter\wst_cursors.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="wst_cursors"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="test_wst_cursors.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="test_wst_cursors"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="wst_collections.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="wst_collections"/>
|
||||
</Unit15>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@@ -16,7 +16,8 @@ uses
|
||||
server_service_xmlrpc, test_parsers, wsdl_generator, xsd_generator,
|
||||
xsd_consts, base_json_formatter, wsdl_parser, test_support, basex_encode,
|
||||
test_basex_encode, json_formatter, server_service_json, test_json,
|
||||
test_suite_utils, test_generators, fpcunittestrunner;
|
||||
test_suite_utils, test_generators, fpcunittestrunner, test_std_cursors,
|
||||
test_rtti_filter, rtti_filters, wst_cursors, test_wst_cursors;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
|
Reference in New Issue
Block a user