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 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:
|
2016-01-23 16:44:50 +00:00
|
|
|
echo "[scalarEvent] expected anchor ", expected.scalarAnchor,
|
2015-12-22 15:28:35 +00:00
|
|
|
", got ", actual.scalarAnchor
|
2015-12-07 21:09:57 +00:00
|
|
|
elif expected.scalarContent != actual.scalarContent:
|
2016-01-23 16:44:50 +00:00
|
|
|
let msg = "[scalarEvent] expected content \"" &
|
2015-12-17 20:44:41 +00:00
|
|
|
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:
|
2016-01-23 16:44:50 +00:00
|
|
|
echo "[scalarEvent] 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
|
|
|
|
i = 0
|
2016-01-24 10:44:10 +00:00
|
|
|
parser = newYamlParser(tagLib)
|
|
|
|
events = parser.parse(newStringStream(input))
|
2016-01-05 17:14:11 +00:00
|
|
|
try:
|
2016-02-12 18:53:25 +00:00
|
|
|
for token in events:
|
2016-01-05 17:14:11 +00:00
|
|
|
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-24 10:44:10 +00:00
|
|
|
var tagLib = initCoreTagLibrary()
|
2015-12-28 21:03:16 +00:00
|
|
|
teardown:
|
|
|
|
discard
|
2015-12-21 22:10:42 +00:00
|
|
|
|
2016-01-23 16:44:50 +00:00
|
|
|
test "Parsing: Simple scalarEvent":
|
|
|
|
ensure("scalarEvent", startDocEvent(), scalarEvent("scalarEvent"), endDocEvent())
|
2015-12-07 21:09:57 +00:00
|
|
|
test "Parsing: Simple Sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("- off", startDocEvent(), startSeqEvent(),
|
|
|
|
scalarEvent("off"), endSeqEvent(), endDocEvent())
|
2015-12-07 21:09:57 +00:00
|
|
|
test "Parsing: Simple Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("42: value\nkey2: -7.5", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("42"), scalarEvent("value"), scalarEvent("key2"),
|
|
|
|
scalarEvent("-7.5"), endMapEvent(), endDocEvent())
|
2015-12-10 22:02:06 +00:00
|
|
|
test "Parsing: Explicit Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("? null\n: value\n? ON\n: value2", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("null"), scalarEvent("value"),
|
|
|
|
scalarEvent("ON"), scalarEvent("value2"),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-22 20:08:58 +00:00
|
|
|
test "Parsing: Mixed Map (explicit to implicit)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("? a\n: 13\n1.5: d", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
scalarEvent("13"), scalarEvent("1.5"),
|
|
|
|
scalarEvent("d"), endMapEvent(), endDocEvent())
|
2015-12-22 20:08:58 +00:00
|
|
|
test "Parsing: Mixed Map (implicit to explicit)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: 4.2\n? 23\n: d", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
scalarEvent("4.2"), scalarEvent("23"),
|
|
|
|
scalarEvent("d"), endMapEvent(), endDocEvent())
|
2015-12-22 21:28:27 +00:00
|
|
|
test "Parsing: Missing values in map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("? a\n? b\nc:", startDocEvent(), startMapEvent(), scalarEvent("a"), scalarEvent(""),
|
|
|
|
scalarEvent("b"), scalarEvent(""), scalarEvent("c"), scalarEvent(""), endMapEvent(),
|
|
|
|
endDocEvent())
|
2015-12-22 21:28:27 +00:00
|
|
|
test "Parsing: Missing keys in map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure(": a\n: b", startDocEvent(), startMapEvent(), scalarEvent(""), scalarEvent("a"),
|
|
|
|
scalarEvent(""), scalarEvent("b"), endMapEvent(), endDocEvent())
|
|
|
|
test "Parsing: Multiline scalarEvents in explicit map":
|
|
|
|
ensure("? a\n true\n: null\n d\n? e\n 42", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a true"), scalarEvent("null d"), scalarEvent("e 42"), scalarEvent(""),
|
|
|
|
endMapEvent(), endDocEvent())
|
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",
|
2016-01-23 16:44:50 +00:00
|
|
|
startDocEvent(), startSeqEvent(), startMapEvent(), scalarEvent("key"),
|
|
|
|
scalarEvent("value"), scalarEvent("key2"), scalarEvent("value2"), endMapEvent(),
|
|
|
|
startMapEvent(), scalarEvent("key3"), scalarEvent("value3"), endMapEvent(),
|
|
|
|
endSeqEvent(), endDocEvent())
|
2015-12-10 19:53:43 +00:00
|
|
|
test "Parsing: Sequence in Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("key:\n - item1\n - item2", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("key"), startSeqEvent(), scalarEvent("item1"), scalarEvent("item2"),
|
|
|
|
endSeqEvent(), endMapEvent(), endDocEvent())
|
2015-12-10 19:53:43 +00:00
|
|
|
test "Parsing: Sequence in Sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("- - l1_i1\n - l1_i2\n- l2_i1", startDocEvent(), startSeqEvent(),
|
|
|
|
startSeqEvent(), scalarEvent("l1_i1"), scalarEvent("l1_i2"), endSeqEvent(),
|
|
|
|
scalarEvent("l2_i1"), endSeqEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("[2, b]", startDocEvent(), startSeqEvent(), scalarEvent("2"),
|
|
|
|
scalarEvent("b"), endSeqEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("{a: Y, 1.337: d}", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
scalarEvent("Y"), scalarEvent("1.337"),
|
|
|
|
scalarEvent("d"), endMapEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence in Flow Sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("[a, [b, c]]", startDocEvent(), startSeqEvent(), scalarEvent("a"),
|
|
|
|
startSeqEvent(), scalarEvent("b"), scalarEvent("c"), endSeqEvent(),
|
|
|
|
endSeqEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence in Flow Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("{a: [b, c], [d, e]: f}", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
startSeqEvent(), scalarEvent("b"), scalarEvent("c"), endSeqEvent(),
|
|
|
|
startSeqEvent(), scalarEvent("d"), scalarEvent("e"), endSeqEvent(),
|
|
|
|
scalarEvent("f"), endMapEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Sequence in Map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: [b, c]", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
startSeqEvent(), scalarEvent("b"), scalarEvent("c"), endSeqEvent(),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-10 21:28:57 +00:00
|
|
|
test "Parsing: Flow Map in Sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("- {a: b}", startDocEvent(), startSeqEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
scalarEvent("b"), endMapEvent(), endSeqEvent(), endDocEvent())
|
2015-12-14 20:26:34 +00:00
|
|
|
test "Parsing: Multiline scalar (top level)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a\nb \n c\nd", startDocEvent(), scalarEvent("a b c d"), endDocEvent())
|
2015-12-14 20:26:34 +00:00
|
|
|
test "Parsing: Multiline scalar (in map)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: b\n c\nd:\n e\n f", startDocEvent(), startMapEvent(), scalarEvent("a"),
|
|
|
|
scalarEvent("b c"), scalarEvent("d"), scalarEvent("e f"), endMapEvent(), endDocEvent())
|
2015-12-17 20:44:41 +00:00
|
|
|
test "Parsing: Block scalar (literal)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: |\x0A ab\x0A \x0A cd\x0A ef\x0A \x0A", startDocEvent(),
|
|
|
|
startMapEvent(), scalarEvent("a"), scalarEvent("ab\x0A\x0Acd\x0Aef\x0A", yTagExclamationmark),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-17 20:44:41 +00:00
|
|
|
test "Parsing: Block scalar (folded)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: >\x0A ab\x0A cd\x0A \x0A ef\x0A\x0A\x0A gh\x0A", startDocEvent(),
|
|
|
|
startMapEvent(), scalarEvent("a"), scalarEvent("ab cd\x0Aef\x0A\x0Agh\x0A", yTagExclamationmark),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-17 20:44:41 +00:00
|
|
|
test "Parsing: Block scalar (keep)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: |+\x0A ab\x0A \x0A \x0A", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a"), scalarEvent("ab\x0A\x0A \x0A", yTagExclamationmark), endMapEvent(), endDocEvent())
|
2015-12-17 20:44:41 +00:00
|
|
|
test "Parsing: Block scalar (strip)":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("a: |-\x0A ab\x0A \x0A \x0A", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a"), scalarEvent("ab", yTagExclamationmark), endMapEvent(), endDocEvent())
|
2015-12-21 20:58:28 +00:00
|
|
|
test "Parsing: non-specific tags of quoted strings":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("\"a\"", startDocEvent(),
|
|
|
|
scalarEvent("a", yTagExclamationMark), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: explicit non-specific tag":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("! a", startDocEvent(), scalarEvent("a", yTagExclamationMark), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: secondary tag handle resolution":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("!!str a", startDocEvent(), scalarEvent("a", yTagString), endDocEvent())
|
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")
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("%TAG !t! tag:example.com,2015:\n---\n!t!foo a", startDocEvent(),
|
|
|
|
scalarEvent("a", fooId), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure(" - !!str a\n - b\n - !!int c\n - d", startDocEvent(),
|
|
|
|
startSeqEvent(), scalarEvent("a", yTagString), scalarEvent("b"),
|
|
|
|
scalarEvent("c", yTagInteger), scalarEvent("d"), endSeqEvent(), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in implicit map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("!!str a: b\nc: !!int d\ne: !!str f\ng: h", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a", yTagString), scalarEvent("b"), scalarEvent("c"),
|
|
|
|
scalarEvent("d", yTagInteger), scalarEvent("e"), scalarEvent("f", yTagString),
|
|
|
|
scalarEvent("g"), scalarEvent("h"), endMapEvent(), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags in explicit map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("? !!str a\n: !!int b\n? c\n: !!str d", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a", yTagString), scalarEvent("b", yTagInteger), scalarEvent("c"),
|
|
|
|
scalarEvent("d", yTagString), endMapEvent(), endDocEvent())
|
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",
|
2016-01-23 16:44:50 +00:00
|
|
|
startDocEvent(), startMapEvent(yTagMap), scalarEvent("foo"),
|
|
|
|
startSeqEvent(yTagSequence), scalarEvent("a"), scalarEvent("b", yTagString),
|
|
|
|
endSeqEvent(), scalarEvent("bar", yTagString),
|
|
|
|
scalarEvent("baz", yTagString), endMapEvent(), endDocEvent())
|
2016-01-04 20:46:33 +00:00
|
|
|
test "Parsing: root tag for block sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("--- !!seq\n- a", startDocEvent(), startSeqEvent(yTagSequence),
|
|
|
|
scalarEvent("a"), endSeqEvent(), endDocEvent())
|
2016-01-04 20:46:33 +00:00
|
|
|
test "Parsing: root tag for explicit block map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("--- !!map\n? a\n: b", startDocEvent(), startMapEvent(yTagMap),
|
|
|
|
scalarEvent("a"), scalarEvent("b"), endMapEvent(), endDocEvent())
|
2015-12-21 22:10:42 +00:00
|
|
|
test "Parsing: tags for flow objects":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("!!map { k: !!seq [ a, !!str b] }", startDocEvent(), startMapEvent(yTagMap),
|
|
|
|
scalarEvent("k"), startSeqEvent(yTagSequence), scalarEvent("a"),
|
|
|
|
scalarEvent("b", yTagString), endSeqEvent(), endMapEvent(), endDocEvent())
|
2015-12-22 17:51:16 +00:00
|
|
|
test "Parsing: Tag after directives end":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("--- !!str\nfoo", startDocEvent(), scalarEvent("foo", yTagString), endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Simple Anchor":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("&a str", startDocEvent(), scalarEvent("str", yTagQuestionMark,
|
|
|
|
0.AnchorId), endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Anchors in sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure(" - &a a\n - b\n - &c c\n - &a d", startDocEvent(), startSeqEvent(),
|
|
|
|
scalarEvent("a", yTagQuestionMark, 0.AnchorId), scalarEvent("b"),
|
|
|
|
scalarEvent("c", yTagQuestionMark, 1.AnchorId),
|
|
|
|
scalarEvent("d", yTagQuestionMark, 2.AnchorId), endSeqEvent(),
|
|
|
|
endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Anchors in map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("&a a: b\nc: &d d", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a", yTagQuestionMark, 0.AnchorId),
|
|
|
|
scalarEvent("b"), scalarEvent("c"),
|
|
|
|
scalarEvent("d", yTagQuestionMark, 1.AnchorId),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Anchors and tags":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure(" - &a !!str a\n - !!int b\n - &c !!int c\n - &d d", startDocEvent(),
|
|
|
|
startSeqEvent(), scalarEvent("a", yTagString, 0.AnchorId),
|
|
|
|
scalarEvent("b", yTagInteger), scalarEvent("c", yTagInteger, 1.AnchorId),
|
|
|
|
scalarEvent("d", yTagQuestionMark, 2.AnchorId), endSeqEvent(),
|
|
|
|
endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Aliases in sequence":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure(" - &a a\n - &b b\n - *a\n - *b", startDocEvent(), startSeqEvent(),
|
|
|
|
scalarEvent("a", yTagQuestionMark, 0.AnchorId),
|
|
|
|
scalarEvent("b", yTagQuestionMark, 1.AnchorId), aliasEvent(0.AnchorId),
|
|
|
|
aliasEvent(1.AnchorId), endSeqEvent(), endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Aliases in map":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("&a a: &b b\n*a : *b", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("a", yTagQuestionMark, 0.AnchorId),
|
|
|
|
scalarEvent("b", yTagQuestionMark, 1.AnchorId), aliasEvent(0.AnchorId),
|
|
|
|
aliasEvent(1.AnchorId), endMapEvent(), endDocEvent())
|
2015-12-22 15:28:35 +00:00
|
|
|
test "Parsing: Aliases in flow":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("{ &a [a, &b b]: *b, *a : [c, *b, d]}", startDocEvent(), startMapEvent(),
|
|
|
|
startSeqEvent(yTagQuestionMark, 0.AnchorId), scalarEvent("a"),
|
|
|
|
scalarEvent("b", yTagQuestionMark, 1.AnchorId), endSeqEvent(),
|
|
|
|
aliasEvent(1.AnchorId), aliasEvent(0.AnchorId), startSeqEvent(),
|
|
|
|
scalarEvent("c"), aliasEvent(1.AnchorId), scalarEvent("d"), endSeqEvent(),
|
|
|
|
endMapEvent(), endDocEvent())
|
2015-12-23 17:12:51 +00:00
|
|
|
test "Parsing: Tags on empty scalars":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("!!str : a\nb: !!int\n!!str : !!str", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("", yTagString), scalarEvent("a"), scalarEvent("b"),
|
|
|
|
scalarEvent("", yTagInteger), scalarEvent("", yTagString),
|
|
|
|
scalarEvent("", yTagString), endMapEvent(), endDocEvent())
|
2015-12-23 17:12:51 +00:00
|
|
|
test "Parsing: Anchors on empty scalars":
|
2016-01-23 16:44:50 +00:00
|
|
|
ensure("&a : a\nb: &b\n&c : &a", startDocEvent(), startMapEvent(),
|
|
|
|
scalarEvent("", yTagQuestionMark, 0.AnchorId), scalarEvent("a"),
|
|
|
|
scalarEvent("b"), scalarEvent("", yTagQuestionMark, 1.AnchorId),
|
|
|
|
scalarEvent("", yTagQuestionMark, 2.AnchorId),
|
|
|
|
scalarEvent("", yTagQuestionMark, 3.AnchorId), endMapEvent(), endDocEvent())
|