comments.json empty.json enum-empty.json enum-missing-data.json \
enum-wrong-data.json enum-int-member.json enum-dict-member.json \
enum-clash-member.json enum-max-member.json enum-union-clash.json \
- enum-bad-name.json \
- funny-char.json indented-expr.json \
+ enum-bad-name.json funny-char.json indented-expr.json \
+ missing-type.json bad-ident.json ident-with-escape.json \
+ double-type.json bad-base.json bad-type-bool.json bad-type-int.json \
+ bad-type-dict.json double-data.json unknown-expr-key.json \
missing-colon.json missing-comma-list.json \
missing-comma-object.json non-objects.json \
qapi-schema-test.json quoted-structural-chars.json \
include-simple.json include-relpath.json include-format-err.json \
include-non-file.json include-no-file.json include-before-err.json \
include-nested-err.json include-self-cycle.json include-cycle.json \
- include-repetition.json event-nest-struct.json)
+ include-repetition.json event-nest-struct.json event-case.json)
GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h \
tests/test-qmp-commands.h tests/test-qapi-event.h
--- /dev/null
+# FIXME: we should reject a base that is not a struct
+{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
+{ 'type': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
--- /dev/null
+[OrderedDict([('union', 'Union'), ('data', OrderedDict([('a', 'int'), ('b', 'str')]))]),
+ OrderedDict([('type', 'MyType'), ('base', 'Union'), ('data', OrderedDict([('c', 'int')]))])]
+[{'enum_name': 'UnionKind', 'enum_values': None}]
+[OrderedDict([('type', 'MyType'), ('base', 'Union'), ('data', OrderedDict([('c', 'int')]))])]
--- /dev/null
+# FIXME: we should reject creating a type name with bad name
+{ 'type': '*oops', 'data': { 'i': 'int' } }
--- /dev/null
+[OrderedDict([('type', '*oops'), ('data', OrderedDict([('i', 'int')]))])]
+[]
+[OrderedDict([('type', '*oops'), ('data', OrderedDict([('i', 'int')]))])]
--- /dev/null
+tests/qapi-schema/bad-type-bool.json:3:11: Stray "t"
--- /dev/null
+# we reject an expression with a metatype that is not a string
+# FIXME: once the parser understands bool inputs, improve the error message
+{ 'type': true, 'data': { } }
--- /dev/null
+# FIXME: we should reject an expression with a metatype that is not a string
+{ 'command': { } }
--- /dev/null
+[OrderedDict([('command', OrderedDict())])]
+[]
+[]
--- /dev/null
+tests/qapi-schema/bad-type-int.json:3:11: Stray "1"
--- /dev/null
+# we reject an expression with a metatype that is not a string
+# FIXME: once the parser understands integer inputs, improve the error message
+{ 'type': 1, 'data': { } }
--- /dev/null
+tests/qapi-schema/double-data.json:2:39: Duplicate key "data"
--- /dev/null
+# we reject an expression with duplicate top-level keys
+{ 'type': 'bar', 'data': { }, 'data': { 'string': 'str'} }
--- /dev/null
+# FIXME: we should reject an expression with ambiguous metatype
+{ 'command': 'foo', 'type': 'bar', 'data': { } }
--- /dev/null
+[OrderedDict([('command', 'foo'), ('type', 'bar'), ('data', OrderedDict())])]
+[]
+[OrderedDict([('command', 'foo'), ('type', 'bar'), ('data', OrderedDict())])]
--- /dev/null
+# TODO: might be nice to enforce naming conventions; but until then this works
+# even though events should usually be ALL_CAPS
+{ 'event': 'oops' }
--- /dev/null
+[OrderedDict([('event', 'oops')])]
+[]
+[]
--- /dev/null
+# FIXME: we should allow escape sequences in strings, if they map back to ASCII
+# { 'command': 'fooA', 'data': { 'bar1': 'str' } }
+{ 'c\u006fmmand': '\u0066\u006f\u006FA',
+ 'd\u0061ta': { '\u0062\u0061\u00721': '\u0073\u0074\u0072' } }
--- /dev/null
+[OrderedDict([('cu006fmmand', 'u0066u006fu006FA'), ('du0061ta', OrderedDict([('u0062u0061u00721', 'u0073u0074u0072')]))])]
+[]
+[]
--- /dev/null
+# FIXME: we should reject an expression with missing metatype
+{ 'data': { } }
--- /dev/null
+[OrderedDict([('data', OrderedDict())])]
+[]
+[]
--- /dev/null
+# FIXME: we should reject an expression with unknown top-level keys
+{ 'type': 'bar', 'data': { 'string': 'str'}, 'bogus': { } }
--- /dev/null
+[OrderedDict([('type', 'bar'), ('data', OrderedDict([('string', 'str')])), ('bogus', OrderedDict())])]
+[]
+[OrderedDict([('type', 'bar'), ('data', OrderedDict([('string', 'str')])), ('bogus', OrderedDict())])]