2015-05-13 15:06:01 +03:00
|
|
|
// Copyright (c) 2015 SharpYaml - Alexandre Mutel
|
2013-11-03 12:55:27 +04:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
// SharpYaml is a fork of YamlDotNet https://github.com/aaubry/YamlDotNet
|
|
|
|
// published with the following license:
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright (c) 2008, 2009, 2010, 2011, 2012 Antoine Aubry
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
// this software and associated documentation files (the "Software"), to deal in
|
|
|
|
// the Software without restriction, including without limitation the rights to
|
|
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
// of the Software, and to permit persons to whom the Software is furnished to do
|
|
|
|
// so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
// copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
// SOFTWARE.
|
2013-10-25 02:45:40 +04:00
|
|
|
using SharpYaml.Events;
|
2013-11-03 12:55:27 +04:00
|
|
|
using SharpYaml.Tokens;
|
|
|
|
using AnchorAlias = SharpYaml.Events.AnchorAlias;
|
|
|
|
using DocumentEnd = SharpYaml.Events.DocumentEnd;
|
|
|
|
using DocumentStart = SharpYaml.Events.DocumentStart;
|
|
|
|
using Scalar = SharpYaml.Events.Scalar;
|
|
|
|
using StreamEnd = SharpYaml.Events.StreamEnd;
|
|
|
|
using StreamStart = SharpYaml.Events.StreamStart;
|
2013-09-11 21:11:39 +04:00
|
|
|
|
2013-11-03 12:55:27 +04:00
|
|
|
namespace SharpYaml.Tests
|
2013-09-11 21:11:39 +04:00
|
|
|
{
|
|
|
|
public class ParserTestHelper : YamlTest
|
|
|
|
{
|
|
|
|
protected const bool Explicit = false;
|
|
|
|
protected const bool Implicit = true;
|
|
|
|
protected const string TagYaml = "tag:yaml.org,2002:";
|
|
|
|
|
|
|
|
protected static readonly TagDirective[] DefaultTags = new[] {
|
|
|
|
new TagDirective("!", "!"),
|
|
|
|
new TagDirective("!!", TagYaml)
|
|
|
|
};
|
|
|
|
|
|
|
|
protected static StreamStart StreamStart
|
|
|
|
{
|
|
|
|
get { return new StreamStart(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static StreamEnd StreamEnd
|
|
|
|
{
|
|
|
|
get { return new StreamEnd(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
protected DocumentStart DocumentStart(bool isImplicit)
|
|
|
|
{
|
|
|
|
return DocumentStart(isImplicit, null, DefaultTags);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected DocumentStart DocumentStart(bool isImplicit, VersionDirective version, params TagDirective[] tags)
|
|
|
|
{
|
|
|
|
return new DocumentStart(version, new TagDirectiveCollection(tags), isImplicit);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected VersionDirective Version(int major, int minor)
|
|
|
|
{
|
|
|
|
return new VersionDirective(new Version(major, minor));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected TagDirective TagDirective(string handle, string prefix)
|
|
|
|
{
|
|
|
|
return new TagDirective(handle, prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected DocumentEnd DocumentEnd(bool isImplicit)
|
|
|
|
{
|
|
|
|
return new DocumentEnd(isImplicit);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar PlainScalar(string text)
|
|
|
|
{
|
|
|
|
return new Scalar(null, null, text, ScalarStyle.Plain, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar SingleQuotedScalar(string text)
|
|
|
|
{
|
|
|
|
return new Scalar(null, null, text, ScalarStyle.SingleQuoted, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar DoubleQuotedScalar(string text)
|
|
|
|
{
|
|
|
|
return DoubleQuotedScalar(null, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar ExplicitDoubleQuotedScalar(string tag, string text)
|
|
|
|
{
|
|
|
|
return DoubleQuotedScalar(tag, text, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar DoubleQuotedScalar(string tag, string text, bool quotedImplicit = true)
|
|
|
|
{
|
|
|
|
return new Scalar(null, tag, text, ScalarStyle.DoubleQuoted, false, quotedImplicit);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar LiteralScalar(string text)
|
|
|
|
{
|
|
|
|
return new Scalar(null, null, text, ScalarStyle.Literal, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Scalar FoldedScalar(string text)
|
|
|
|
{
|
|
|
|
return new Scalar(null, null, text, ScalarStyle.Folded, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected SequenceStart BlockSequenceStart
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
get { return new SequenceStart(null, null, true, YamlStyle.Block); }
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected SequenceStart FlowSequenceStart
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
get { return new SequenceStart(null, null, true, YamlStyle.Flow); }
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected SequenceStart AnchoredFlowSequenceStart(string anchor)
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
return new SequenceStart(anchor, null, true, YamlStyle.Flow);
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected SequenceEnd SequenceEnd
|
|
|
|
{
|
|
|
|
get { return new SequenceEnd(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
protected MappingStart BlockMappingStart
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
get { return new MappingStart(null, null, true, YamlStyle.Block); }
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected MappingStart TaggedBlockMappingStart(string tag)
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
return new MappingStart(null, tag, false, YamlStyle.Block);
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected MappingStart FlowMappingStart
|
|
|
|
{
|
2013-10-19 17:16:34 +04:00
|
|
|
get { return new MappingStart(null, null, true, YamlStyle.Flow); }
|
2013-09-11 21:11:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected MappingEnd MappingEnd
|
|
|
|
{
|
|
|
|
get { return new MappingEnd(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
protected AnchorAlias AnchorAlias(string alias)
|
|
|
|
{
|
|
|
|
return new AnchorAlias(alias);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|