mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 23:29:50 +02:00
* Handle case where there is no end-of-document
This commit is contained in:
parent
2f086e1ec2
commit
e9eb8297bc
packages/fcl-yaml
@ -437,7 +437,7 @@ begin
|
||||
ConsumeToken;
|
||||
lToken:=Peek;
|
||||
end;
|
||||
While not (lToken.token in [ytEOF,ytDocumentEnd]) do
|
||||
While not (lToken.token in [ytEOF,ytDocumentStart,ytDocumentEnd]) do
|
||||
begin
|
||||
case lToken.Token of
|
||||
ytAnchor : ParseAnchor;
|
||||
|
@ -24,11 +24,6 @@
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="FCL"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="testyaml.lpr"/>
|
||||
@ -38,10 +33,6 @@
|
||||
<Filename Value="utyamlparser.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="../src/fpyaml.data.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="../src/fpyaml.scanner.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -70,6 +61,10 @@
|
||||
<Filename Value="../src/fpyaml.strings.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="../src/fpyaml.data.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -79,11 +74,12 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="src"/>
|
||||
<OtherUnitFiles Value="src;../src"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf3"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
|
@ -47,6 +47,8 @@ type
|
||||
procedure TestCreate;
|
||||
procedure TestEmptyDocument;
|
||||
procedure TestVersionEmptyDocument;
|
||||
procedure TestMultiDocument;
|
||||
procedure TestMultiDocumentNoEnd;
|
||||
procedure TestScalar;
|
||||
procedure TestAnchoredScalar;
|
||||
procedure TestBlockSequence;
|
||||
@ -506,6 +508,46 @@ begin
|
||||
AssertEquals('Document empty',0,Document.Count);
|
||||
end;
|
||||
|
||||
procedure TTestYamlParser.TestMultiDocument;
|
||||
var
|
||||
doc : TYAMLDocument;
|
||||
begin
|
||||
Parse(['%YAML 1.2','---','abc','...','---','def','...']);
|
||||
AssertNotNull('Data',Data);
|
||||
AssertEquals('YAML Stream',TYAMLStream,Data.ClassType);
|
||||
AssertEquals('YAML Stream item count',2,YAML.Count);
|
||||
AssertEquals('YAML Stream document count',2,YAML.DocumentCount);
|
||||
Doc:=YAML.Documents[0];
|
||||
AssertNotNull('Document 1',Doc);
|
||||
AssertEquals('Document 1 Major',1,Doc.Version.Major);
|
||||
AssertEquals('Document 1 Minor',2,Doc.Version.Minor);
|
||||
AssertEquals('Document 1 element count',1,Doc.Count);
|
||||
AssertScalar('Document 1 element',Doc[0],yttString,'abc');
|
||||
Doc:=YAML.Documents[1];
|
||||
AssertNotNull('Document 2',doc);
|
||||
AssertEquals('Document 2 element count',1,Doc.Count);
|
||||
AssertScalar('Document 2 element',Doc[0],yttString,'def');
|
||||
end;
|
||||
|
||||
procedure TTestYamlParser.TestMultiDocumentNoEnd;
|
||||
var
|
||||
doc : TYAMLDocument;
|
||||
begin
|
||||
Parse(['abc','---','def']);
|
||||
AssertNotNull('Data',Data);
|
||||
AssertEquals('YAML Stream',TYAMLStream,Data.ClassType);
|
||||
AssertEquals('YAML Stream item count',2,YAML.Count);
|
||||
AssertEquals('YAML Stream document count',2,YAML.DocumentCount);
|
||||
Doc:=YAML.Documents[0];
|
||||
AssertNotNull('Document 1',Doc);
|
||||
AssertEquals('Document 1 element count',1,Doc.Count);
|
||||
AssertScalar('Document 1 element',Doc[0],yttString,'abc');
|
||||
Doc:=YAML.Documents[1];
|
||||
AssertNotNull('Document 2',doc);
|
||||
AssertEquals('Document 2 element count',1,Doc.Count);
|
||||
AssertScalar('Document 2 element',Doc[0],yttString,'def');
|
||||
end;
|
||||
|
||||
function TTestYamlParser.GetDocument: TYAMLDocument;
|
||||
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user