mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Added seq gen emitter tests
This commit is contained in:
@@ -52,8 +52,31 @@ def scalar(value, tag='', anchor='', anchor_id=0):
|
||||
def comment(value):
|
||||
return {'emit': 'YAML::Comment("%s")' % value, 'handle': ''}
|
||||
|
||||
def seq_start(tag='', anchor='', anchor_id=0):
|
||||
emit = []
|
||||
if tag:
|
||||
emit += ['YAML::VerbatimTag("%s")' % encode(tag)]
|
||||
if anchor:
|
||||
emit += ['YAML::Anchor("%s")' % encode(anchor)]
|
||||
if tag:
|
||||
out_tag = encode(tag)
|
||||
else:
|
||||
out_tag = '?'
|
||||
emit += ['YAML::BeginSeq']
|
||||
return {'emit': emit, 'handle': 'SEQ_START("%s", %s)' % (out_tag, anchor_id)}
|
||||
|
||||
def seq_end():
|
||||
return {'emit': 'YAML::EndSeq', 'handle': 'SEQ_END()'}
|
||||
|
||||
def gen_templates():
|
||||
yield [[doc_start(), doc_start(True)], [scalar('foo'), scalar('foo\n')], [doc_end(), doc_end(True)]]
|
||||
yield [[doc_start(), doc_start(True)],
|
||||
[scalar('foo'), scalar('foo\n'), scalar('foo', 'tag'), scalar('foo', '', 'anchor', 1)],
|
||||
[doc_end(), doc_end(True)]]
|
||||
yield [[doc_start(), doc_start(True)],
|
||||
[seq_start()],
|
||||
[[], [scalar('foo')], [scalar('foo', 'tag')], [scalar('foo', '', 'anchor', 1)], [scalar('foo', 'tag', 'anchor', 1)], [scalar('foo'), scalar('bar')], [scalar('foo', 'tag', 'anchor', 1), scalar('bar', 'tag', 'other', 2)]],
|
||||
[seq_end()],
|
||||
[doc_end(), doc_end(True)]]
|
||||
|
||||
def expand(template):
|
||||
if len(template) == 0:
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user