2015-12-28 21:03:16 +00:00
|
|
|
import "../yaml"
|
2015-12-07 21:09:57 +00:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc startDoc(): YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlStartDocument
|
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc endDoc(): YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlEndDocument
|
|
|
|
|
2015-12-23 17:12:51 +00:00
|
|
|
proc scalar(content: string,
|
2015-12-27 22:40:27 +00:00
|
|
|
tag: TagId = yTagQuestionMark, anchor: AnchorId = yAnchorNone):
|
2016-01-14 18:58:38 +00:00
|
|
|
YamlStreamEvent = scalarEvent(content, tag, anchor)
|
2015-12-07 21:09:57 +00:00
|
|
|
|
2015-12-27 22:40:27 +00:00
|
|
|
proc startSequence(tag: TagId = yTagQuestionMark,
|
|
|
|
anchor: AnchorId = yAnchorNone):
|
2015-12-26 12:39:43 +00:00
|
|
|
YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlStartSequence
|
2015-12-27 15:36:32 +00:00
|
|
|
result.seqAnchor = anchor
|
|
|
|
result.seqTag = tag
|
2015-12-07 21:09:57 +00:00
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc endSequence(): YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlEndSequence
|
|
|
|
|
2015-12-27 22:40:27 +00:00
|
|
|
proc startMap(tag: TagId = yTagQuestionMark, anchor: AnchorId = yAnchorNone):
|
2015-12-26 12:39:43 +00:00
|
|
|
YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlStartMap
|
2015-12-27 15:36:32 +00:00
|
|
|
result.mapAnchor = anchor
|
|
|
|
result.mapTag = tag
|
2015-12-07 21:09:57 +00:00
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc endMap(): YamlStreamEvent =
|
2015-12-07 21:09:57 +00:00
|
|
|
result.kind = yamlEndMap
|
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc alias(target: AnchorId): YamlStreamEvent =
|
2015-12-22 15:28:35 +00:00
|
|
|
result.kind = yamlAlias
|
|
|
|
result.aliasTarget = target
|
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
proc printDifference(expected, actual: YamlStreamEvent) =
|
2015-12-07 21:09:57 +00:00
|
|
|
if expected.kind != actual.kind:
|
|
|
|
echo "expected " & $expected.kind & ", got " & $actual.kind
|
|
|
|
else:
|
|
|
|
case expected.kind
|
|
|
|
of yamlScalar:
|
|
|
|
if expected.scalarTag != actual.scalarTag:
|
2015-12-21 20:58:28 +00:00
|
|
|
echo "[\"", actual.scalarContent, "\".tag] expected tag ",
|
|
|
|
expected.scalarTag, ", got ", actual.scalarTag
|
2015-12-07 21:09:57 +00:00
|
|
|
elif expected.scalarAnchor != actual.scalarAnchor:
|
2015-12-22 15:28:35 +00:00
|
|
|
echo "[scalar] expected anchor ", expected.scalarAnchor,
|
|
|
|
", got ", actual.scalarAnchor
|
2015-12-07 21:09:57 +00:00
|
|
|
elif expected.scalarContent != actual.scalarContent:
|
2015-12-17 20:44:41 +00:00
|
|
|
let msg = "[scalar] expected content \"" &
|
|
|
|
expected.scalarContent & "\", got \"" &
|
|
|
|
actual.scalarContent & "\" "
|
2015-12-22 21:28:27 +00:00
|
|
|
if expected.scalarContent.len != actual.scalarContent.len:
|
|
|
|
echo msg, "(length does not match)"
|
|
|
|
else:
|
|
|
|
for i in 0..expected.scalarContent.high:
|
|
|
|
if expected.scalarContent[i] != actual.scalarContent[i]:
|
|
|
|
echo msg, "(first different char at pos ", i,
|
|
|
|
": expected ",
|
|
|
|
cast[int](expected.scalarContent[i]),
|
|
|
|
", got ",
|
|
|
|
cast[int](actual.scalarContent[i]), ")"
|
|
|
|
break
|
2015-12-07 21:09:57 +00:00
|
|
|
else:
|
|
|
|
echo "[scalar] Unknown difference"
|
2015-12-27 15:36:32 +00:00
|
|
|
of yamlStartMap:
|
|
|
|
if expected.mapTag != actual.mapTag:
|
|
|
|
echo "[map.tag] expected ", expected.mapTag, ", got ",
|
|
|
|
actual.mapTag
|
2015-12-22 15:28:35 +00:00
|
|
|
else:
|
2015-12-27 15:36:32 +00:00
|
|
|
echo "[map.tag] Unknown difference"
|
|
|
|
of yamlStartSequence:
|
|
|
|
if expected.seqTag != actual.seqTag:
|
|
|
|
echo "[seq.tag] expected ", expected.seqTag, ", got ",
|
|
|
|
actual.seqTag
|
2015-12-22 15:28:35 +00:00
|
|
|
of yamlAlias:
|
|
|
|
if expected.aliasTarget != actual.aliasTarget:
|
|
|
|
echo "[alias] expected ", expected.aliasTarget, ", got ",
|
|
|
|
actual.aliasTarget
|
|
|
|
else:
|
|
|
|
echo "[alias] Unknown difference"
|
2015-12-07 21:09:57 +00:00
|
|
|
else:
|
|
|
|
echo "Unknown difference in event kind " & $expected.kind
|
|
|
|
|
2015-12-26 12:39:43 +00:00
|
|
|
template ensure(input: string, expected: varargs[YamlStreamEvent]) {.dirty.} =
|
2015-12-23 11:35:07 +00:00
|
|
|
var
|
2015-12-26 17:40:23 +00:00
|
|
|
parser = newParser(tagLib)
|
2015-12-23 11:35:07 +00:00
|
|
|
i = 0
|
|
|
|
events = parser.parse(newStringStream(input))
|
2016-01-05 17:14:11 +00:00
|
|
|
try:
|
|
|
|
for token in events():
|
|
|
|
if i >= expected.len:
|
|
|
|
echo "received more tokens than expected (next token = ",
|
|
|
|
token.kind, ")"
|
|
|
|
fail()
|
|
|
|
break
|
|
|
|
if token != expected[i]:
|
|
|
|
echo "at token #" & $i & ":"
|
|
|
|
printDifference(expected[i], token)
|
|
|
|
fail()
|
|
|
|
break
|
|
|
|
i.inc()
|
|
|
|
except YamlParserError:
|
2016-01-05 18:06:55 +00:00
|
|
|
let e = cast[ref YamlParserError](getCurrentException())
|
2016-01-05 17:14:11 +00:00
|
|
|
echo "Parser error:", getCurrentExceptionMsg()
|
|
|
|
echo e.lineContent
|
|
|
|
fail()
|
2015-12-07 21:09:57 +00:00
|
|
|
|
|
|
|
suite "Parsing":
|
2015-12-21 22:10:42 +00:00
|
|
|
setup:
|
2016-01-14 21:51:30 +00:00
|
|
|
var tagLib = coreTagLibrary
|
2015-12-28 21:03:16 +00:00
|
|
|
teardown:
|
|
|
|
discard
|
2015-12-21 22:10:42 +00:00
|
|
|
|
2015-12-07 21:09:57 +00:00
|
|
|
test "Parsing: Simple Scalar":
|
|
|
|
ensure("Scalar", startDoc(), scalar("Scalar"), endDoc())
|
|
|
|
test "Parsing: Simple Sequence":
|
2015-12-27 20:36:47 +00:00
|
|
|
ensure("- off", startDoc(), startSequence(),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("off"), endSequence(), endDoc())
|
2015-12-07 21:09:57 +00:00
|
|
|
test "Parsing: Simple Map":
|
2015-12-23 17:12:51 +00:00
|
|
|
ensure("42: value\nkey2: -7.5", startDoc(), startMap(),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("42"), scalar("value"), scalar("key2"),
|
|
|
|
scalar("-7.5"), endMap(), endDoc())
|
2015-12-10 22:02:06 +00:00
|
|
|
test "Parsing: Explicit Map":
|
2015-12-27 20:36:47 +00:00
|
|
|
ensure("? null\n: value\n? ON\n: value2", startDoc(), startMap(),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("null"), scalar("value"),
|
|
|
|
scalar("ON"), scalar("value2"),
|
2015-12-10 22:02:06 +00:00
|
|
|
endMap(), endDoc())
|
2015-12-22 20:08:58 +00:00
|
|
|
test "Parsing: Mixed Map (explicit to implicit)":
|
2015-12-23 17:12:51 +00:00
|
|
|
ensure("? a\n: 13\n1.5: d", startDoc(), startMap(), scalar("a"),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("13"), scalar("1.5"),
|
2015-12-23 17:12:51 +00:00
|
|
|
scalar("d"), endMap(), endDoc())
|
2015-12-22 20:08:58 +00:00
|
|
|
test "Parsing: Mixed Map (implicit to explicit)":
|
2015-12-23 17:12:51 +00:00
|
|
|
ensure("a: 4.2\n? 23\n: d", startDoc(), startMap(), scalar("a"),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("4.2"), scalar("23"),
|
2015-12-23 17:12:51 +00:00
|
|
|
scalar("d"), endMap(), endDoc())
|
2015-12-22 21:28:27 +00:00
|
|
|
test "Parsing: Missing values in map":
|
|
|
|
ensure("? a\n? b\nc:", startDoc(), startMap(), scalar("a"), scalar(""),
|
|
|
|
scalar("b"), scalar(""), scalar("c"), scalar(""), endMap(),
|
|
|
|
endDoc())
|
|
|
|
test "Parsing: Missing keys in map":
|
|
|
|
ensure(": a\n: b", startDoc(), startMap(), scalar(""), scalar("a"),
|
|
|
|
scalar(""), scalar("b"), endMap(), endDoc())
|
|
|
|
test "Parsing: Multiline scalars in explicit map":
|
2015-12-23 17:12:51 +00:00
|
|
|
ensure("? a\n true\n: null\n d\n? e\n 42", startDoc(), startMap(),
|
|
|
|
scalar("a true"), scalar("null d"), scalar("e 42"), scalar(""),
|
2015-12-22 21:28:27 +00:00
|
|
|
endMap(), endDoc())
|
2015-12-10 19:53:43 +00:00
|
|
|
test "Parsing: Map in Sequence":
|
2015-12-24 14:21:49 +00:00
|
|
|
ensure(" - key: value\n key2: value2\n -\n key3: value3",
|
|
|
|
startDoc(), startSequence(), startMap(), scalar("key"),
|
|
|
|
scalar("value"), scalar("key2"), scalar("value2"), endMap(),
|
|
|
|
startMap(), scalar("key3"), scalar("value3"), endMap(),
|
|
|
|
endSequence(), endDoc())
|
2015-12-10 19:53:43 +00:00
|
|
|
test "Parsing: Sequence in Map":
|
|
|
|
ensure("key:\n - item1\n - item2", startDoc(), startMap(),
|
|
|
|
scalar("key"), startSequence(), scalar("item1"), scalar("item2"),
|
|
|
|
endSequence(), endMap(), endDoc())
|
|
|
|
test "Parsing: Sequence in Sequence":
|
|
|
|
ensure("- - l1_i1\n - l1_i2\n- l2_i1", startDoc(), startSequence(),
|
|
|
|
startSequence(), scalar("l1_i1"), scalar("l1_i2"), endSequence(),
|
2015-12-10 21:28:57 +00:00
|
|
|
scalar("l2_i1"), endSequence(), endDoc())
|
|
|
|
test "Parsing: Flow Sequence":
|
2016-01-14 18:58:38 +00:00
|
|
|
ensure("[2, b]", startDoc(), startSequence(), scalar("2"),
|
2015-12-23 17:12:51 +00:00
|
|
|
scalar("b"), endSequence(), endDoc())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Map":
|
2015-12-27 20:36:47 +00:00
|
|
|
ensure("{a: Y, 1.337: d}", startDoc(), startMap(), scalar("a"),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("Y"), scalar("1.337"),
|
2015-12-23 17:12:51 +00:00
|
|
|
scalar("d"), endMap(), endDoc())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence in Flow Sequence":
|
|
|
|
ensure("[a, [b, c]]", startDoc(), startSequence(), scalar("a"),
|
|
|
|
startSequence(), scalar("b"), scalar("c"), endSequence(),
|
|
|
|
endSequence(), endDoc())
|
|
|
|
test "Parsing: Flow Sequence in Flow Map":
|
2015-12-22 15:28:35 +00:00
|
|
|
ensure("{a: [b, c], [d, e]: f}", startDoc(), startMap(), scalar("a"),
|
2015-12-10 21:28:57 +00:00
|
|
|
startSequence(), scalar("b"), scalar("c"), endSequence(),
|
2015-12-22 15:28:35 +00:00
|
|
|
startSequence(), scalar("d"), scalar("e"), endSequence(),
|
|
|
|
scalar("f"), endMap(), endDoc())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence in Map":
|
|
|
|
ensure("a: [b, c]", startDoc(), startMap(), scalar("a"),
|
|
|
|
startSequence(), scalar("b"), scalar("c"), endSequence(),
|
|
|
|
endMap(), endDoc())
|
|
|
|
test "Parsing: Flow Map in Sequence":
|
|
|
|
ensure("- {a: b}", startDoc(), startSequence(), startMap(), scalar("a"),
|
2015-12-14 20:26:34 +00:00
|
|
|
scalar("b"), endMap(), endSequence(), endDoc())
|
|
|
|
test "Parsing: Multiline scalar (top level)":
|
|
|
|
ensure("a\nb \n c\nd", startDoc(), scalar("a b c d"), endDoc())
|
|
|
|
test "Parsing: Multiline scalar (in map)":
|
|
|
|
ensure("a: b\n c\nd:\n e\n f", startDoc(), startMap(), scalar("a"),
|
2015-12-17 20:44:41 +00:00
|
|
|
scalar("b c"), scalar("d"), scalar("e f"), endMap(), endDoc())
|
|
|
|
test "Parsing: Block scalar (literal)":
|
|
|
|
ensure("a: |\x0A ab\x0A \x0A cd\x0A ef\x0A \x0A", startDoc(),
|
|
|
|
startMap(), scalar("a"), scalar("ab\x0A\x0Acd\x0Aef\x0A"),
|
|
|
|
endMap(), endDoc())
|
|
|
|
test "Parsing: Block scalar (folded)":
|
|
|
|
ensure("a: >\x0A ab\x0A cd\x0A \x0Aef\x0A\x0A\x0Agh\x0A", startDoc(),
|
|
|
|
startMap(), scalar("a"), scalar("ab cd\x0Aef\x0Agh\x0A"),
|
|
|
|
endMap(), endDoc())
|
|
|
|
test "Parsing: Block scalar (keep)":
|
|
|
|
ensure("a: |+\x0A ab\x0A \x0A \x0A", startDoc(), startMap(),
|
|
|
|
scalar("a"), scalar("ab\x0A\x0A \x0A"), endMap(), endDoc())
|
|
|
|
test "Parsing: Block scalar (strip)":
|
|
|
|
ensure("a: |-\x0A ab\x0A \x0A \x0A", startDoc(), startMap(),
|
2015-12-21 20:58:28 +00:00
|
|
|
scalar("a"), scalar("ab"), endMap(), endDoc())
|
|
|
|
test "Parsing: non-specific tags of quoted strings":
|
2015-12-23 17:12:51 +00:00
|
|
|
ensure("\"a\"", startDoc(),
|
2016-01-14 18:58:38 +00:00
|
|
|
scalar("a", yTagExclamationMark), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: explicit non-specific tag":
|
2015-12-27 22:40:27 +00:00
|
|
|
ensure("! a", startDoc(), scalar("a", yTagExclamationMark), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: secondary tag handle resolution":
|
2015-12-27 22:40:27 +00:00
|
|
|
ensure("!!str a", startDoc(), scalar("a", yTagString), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: resolving custom tag handles":
|
2015-12-26 17:40:23 +00:00
|
|
|
let fooId = tagLib.registerUri("tag:example.com,2015:foo")
|
2015-12-21 22:10:42 +00:00
|
|
|
ensure("%TAG !t! tag:example.com,2015:\n---\n!t!foo a", startDoc(),
|
2015-12-26 17:40:23 +00:00
|
|
|
scalar("a", fooId), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in sequence":
|
|
|
|
ensure(" - !!str a\n - b\n - !!int c\n - d", startDoc(),
|
2015-12-27 22:40:27 +00:00
|
|
|
startSequence(), scalar("a", yTagString), scalar("b"),
|
|
|
|
scalar("c", yTagInteger), scalar("d"), endSequence(), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in implicit map":
|
|
|
|
ensure("!!str a: b\nc: !!int d\ne: !!str f\ng: h", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagString), scalar("b"), scalar("c"),
|
|
|
|
scalar("d", yTagInteger), scalar("e"), scalar("f", yTagString),
|
2015-12-26 17:40:23 +00:00
|
|
|
scalar("g"), scalar("h"), endMap(), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in explicit map":
|
|
|
|
ensure("? !!str a\n: !!int b\n? c\n: !!str d", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagString), scalar("b", yTagInteger), scalar("c"),
|
|
|
|
scalar("d", yTagString), endMap(), endDoc())
|
2015-12-27 16:37:42 +00:00
|
|
|
test "Parsing: tags for block objects":
|
|
|
|
ensure("--- !!map\nfoo: !!seq\n - a\n - !!str b\n!!str bar: !!str baz",
|
2015-12-27 22:40:27 +00:00
|
|
|
startDoc(), startMap(yTagMap), scalar("foo"),
|
|
|
|
startSequence(yTagSequence), scalar("a"), scalar("b", yTagString),
|
|
|
|
endSequence(), scalar("bar", yTagString),
|
|
|
|
scalar("baz", yTagString), endMap(), endDoc())
|
2016-01-04 20:46:33 +00:00
|
|
|
test "Parsing: root tag for block sequence":
|
|
|
|
ensure("--- !!seq\n- a", startDoc(), startSequence(yTagSequence),
|
|
|
|
scalar("a"), endSequence(), endDoc())
|
|
|
|
test "Parsing: root tag for explicit block map":
|
|
|
|
ensure("--- !!map\n? a\n: b", startDoc(), startMap(yTagMap),
|
|
|
|
scalar("a"), scalar("b"), endMap(), endDoc())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags for flow objects":
|
2015-12-27 22:40:27 +00:00
|
|
|
ensure("!!map { k: !!seq [ a, !!str b] }", startDoc(), startMap(yTagMap),
|
|
|
|
scalar("k"), startSequence(yTagSequence), scalar("a"),
|
|
|
|
scalar("b", yTagString), endSequence(), endMap(), endDoc())
|
2015-12-22 17:51:16 +00:00
|
|
|
test "Parsing: Tag after directives end":
|
2015-12-27 22:40:27 +00:00
|
|
|
ensure("--- !!str\nfoo", startDoc(), scalar("foo", yTagString), endDoc())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Simple Anchor":
|
2015-12-27 22:40:27 +00:00
|
|
|
ensure("&a str", startDoc(), scalar("str", yTagQuestionMark,
|
2015-12-22 15:28:35 +00:00
|
|
|
0.AnchorId), endDoc())
|
|
|
|
test "Parsing: Anchors in sequence":
|
|
|
|
ensure(" - &a a\n - b\n - &c c\n - &a d", startDoc(), startSequence(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagQuestionMark, 0.AnchorId), scalar("b"),
|
|
|
|
scalar("c", yTagQuestionMark, 1.AnchorId),
|
|
|
|
scalar("d", yTagQuestionMark, 0.AnchorId), endSequence(),
|
2015-12-22 15:28:35 +00:00
|
|
|
endDoc())
|
|
|
|
test "Parsing: Anchors in map":
|
|
|
|
ensure("&a a: b\nc: &d d", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagQuestionMark, 0.AnchorId),
|
2015-12-22 15:28:35 +00:00
|
|
|
scalar("b"), scalar("c"),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("d", yTagQuestionMark, 1.AnchorId),
|
2015-12-22 15:28:35 +00:00
|
|
|
endMap(), endDoc())
|
|
|
|
test "Parsing: Anchors and tags":
|
|
|
|
ensure(" - &a !!str a\n - !!int b\n - &c !!int c\n - &d d", startDoc(),
|
2015-12-27 22:40:27 +00:00
|
|
|
startSequence(), scalar("a", yTagString, 0.AnchorId),
|
|
|
|
scalar("b", yTagInteger), scalar("c", yTagInteger, 1.AnchorId),
|
|
|
|
scalar("d", yTagQuestionMark, 2.AnchorId), endSequence(),
|
2015-12-22 15:28:35 +00:00
|
|
|
endDoc())
|
|
|
|
test "Parsing: Aliases in sequence":
|
|
|
|
ensure(" - &a a\n - &b b\n - *a\n - *b", startDoc(), startSequence(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagQuestionMark, 0.AnchorId),
|
|
|
|
scalar("b", yTagQuestionMark, 1.AnchorId), alias(0.AnchorId),
|
2015-12-22 15:28:35 +00:00
|
|
|
alias(1.AnchorId), endSequence(), endDoc())
|
|
|
|
test "Parsing: Aliases in map":
|
|
|
|
ensure("&a a: &b b\n*a: *b", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("a", yTagQuestionMark, 0.AnchorId),
|
|
|
|
scalar("b", yTagQuestionMark, 1.AnchorId), alias(0.AnchorId),
|
2015-12-22 15:28:35 +00:00
|
|
|
alias(1.AnchorId), endMap(), endDoc())
|
|
|
|
test "Parsing: Aliases in flow":
|
|
|
|
ensure("{ &a [a, &b b]: *b, *a: [c, *b, d]}", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
startSequence(yTagQuestionMark, 0.AnchorId), scalar("a"),
|
|
|
|
scalar("b", yTagQuestionMark, 1.AnchorId), endSequence(),
|
2015-12-22 15:28:35 +00:00
|
|
|
alias(1.AnchorId), alias(0.AnchorId), startSequence(),
|
|
|
|
scalar("c"), alias(1.AnchorId), scalar("d"), endSequence(),
|
2015-12-22 22:35:03 +00:00
|
|
|
endMap(), endDoc())
|
2015-12-23 17:12:51 +00:00
|
|
|
test "Parsing: Tags on empty scalars":
|
2015-12-22 22:35:03 +00:00
|
|
|
ensure("!!str : a\nb: !!int\n!!str : !!str", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("", yTagString), scalar("a"), scalar("b"),
|
|
|
|
scalar("", yTagInteger), scalar("", yTagString),
|
|
|
|
scalar("", yTagString), endMap(), endDoc())
|
2015-12-23 17:12:51 +00:00
|
|
|
test "Parsing: Anchors on empty scalars":
|
2015-12-22 22:35:03 +00:00
|
|
|
ensure("&a : a\nb: &b\n&c : &a", startDoc(), startMap(),
|
2015-12-27 22:40:27 +00:00
|
|
|
scalar("", yTagQuestionMark, 0.AnchorId), scalar("a"),
|
|
|
|
scalar("b"), scalar("", yTagQuestionMark, 1.AnchorId),
|
|
|
|
scalar("", yTagQuestionMark, 2.AnchorId),
|
|
|
|
scalar("", yTagQuestionMark, 0.AnchorId), endMap(), endDoc())
|