mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 21:42:06 -06:00
tests/qapi-schema: Purge simple unions from tests
Drop tests that are specifically about simple unions: * SugaredUnion in doc-good: flat unions are covered by @Object. * union-branch-case and union-clash-branches: branch naming for flat unions is enforced for the tag enum instead, which is covered by enum-member-case and enum-clash-member. * union-empty: empty flat unions are covered by flat-union-empty. Rewrite the remainder to use flat unions: args-union, bad-base, flat-union-base-union, union-branch-invalid-dict, union-unknown. Except drop union-optional-branch. because converting this one is not worth the trouble; we don't explicitly check names beginning with '*' in other places, either. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210917143134.412106-21-armbru@redhat.com>
This commit is contained in:
parent
bb5821dd81
commit
76432d988b
26 changed files with 30 additions and 84 deletions
|
@ -1,2 +1,2 @@
|
||||||
args-union.json: In command 'oops':
|
args-union.json: In command 'oops':
|
||||||
args-union.json:3: command's 'data' can take union type 'Uni' only with 'boxed': true
|
args-union.json:9: command's 'data' can take union type 'Uni' only with 'boxed': true
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
# use of union arguments requires 'boxed':true
|
# use of union arguments requires 'boxed':true
|
||||||
{ 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } }
|
{ 'enum': 'Enum', 'data': [ 'case1', 'case2' ] }
|
||||||
|
{ 'struct': 'Case1', 'data': { 'data': 'int' } }
|
||||||
|
{ 'struct': 'Case2', 'data': { 'data': 'str' } }
|
||||||
|
{ 'union': 'Uni',
|
||||||
|
'base': { 'type': 'Enum' },
|
||||||
|
'discriminator': 'type',
|
||||||
|
'data': { 'case1': 'Case1', 'case2': 'Case2' } }
|
||||||
{ 'command': 'oops', 'data': 'Uni' }
|
{ 'command': 'oops', 'data': 'Uni' }
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
bad-base.json: In struct 'MyType':
|
bad-base.json: In struct 'MyType':
|
||||||
bad-base.json:3: 'base' requires a struct type, union type 'Union' isn't
|
bad-base.json:9: 'base' requires a struct type, union type 'Union' isn't
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
# we reject a base that is not a struct
|
# we reject a base that is not a struct
|
||||||
{ 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
|
{ 'enum': 'Enum', 'data': [ 'a', 'b' ] }
|
||||||
|
{ 'struct': 'Int', 'data': { 'data': 'int' } }
|
||||||
|
{ 'struct': 'Str', 'data': { 'data': 'str' } }
|
||||||
|
{ 'union': 'Union',
|
||||||
|
'base': { 'type': 'Enum' },
|
||||||
|
'discriminator': 'type',
|
||||||
|
'data': { 'a': 'Int', 'b': 'Str' } }
|
||||||
{ 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
|
{ 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
|
||||||
|
|
|
@ -107,15 +107,6 @@
|
||||||
'two': { 'type': 'Variant2',
|
'two': { 'type': 'Variant2',
|
||||||
'if': { 'any': ['IFONE', 'IFTWO'] } } } }
|
'if': { 'any': ['IFONE', 'IFTWO'] } } } }
|
||||||
|
|
||||||
##
|
|
||||||
# @SugaredUnion:
|
|
||||||
# Features:
|
|
||||||
# @union-feat2: a feature
|
|
||||||
##
|
|
||||||
{ 'union': 'SugaredUnion',
|
|
||||||
'features': [ 'union-feat2' ],
|
|
||||||
'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' } } }
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @Alternate:
|
# @Alternate:
|
||||||
# @i: an integer
|
# @i: an integer
|
||||||
|
|
|
@ -32,21 +32,6 @@ object Object
|
||||||
case two: Variant2
|
case two: Variant2
|
||||||
if {'any': ['IFONE', 'IFTWO']}
|
if {'any': ['IFONE', 'IFTWO']}
|
||||||
feature union-feat1
|
feature union-feat1
|
||||||
object q_obj_Variant1-wrapper
|
|
||||||
member data: Variant1 optional=False
|
|
||||||
object q_obj_Variant2-wrapper
|
|
||||||
member data: Variant2 optional=False
|
|
||||||
enum SugaredUnionKind
|
|
||||||
member one
|
|
||||||
member two
|
|
||||||
if IFTWO
|
|
||||||
object SugaredUnion
|
|
||||||
member type: SugaredUnionKind optional=False
|
|
||||||
tag type
|
|
||||||
case one: q_obj_Variant1-wrapper
|
|
||||||
case two: q_obj_Variant2-wrapper
|
|
||||||
if IFTWO
|
|
||||||
feature union-feat2
|
|
||||||
alternate Alternate
|
alternate Alternate
|
||||||
tag type
|
tag type
|
||||||
case i: int
|
case i: int
|
||||||
|
@ -149,13 +134,6 @@ doc symbol=Object
|
||||||
|
|
||||||
feature=union-feat1
|
feature=union-feat1
|
||||||
a feature
|
a feature
|
||||||
doc symbol=SugaredUnion
|
|
||||||
body=
|
|
||||||
|
|
||||||
arg=type
|
|
||||||
|
|
||||||
feature=union-feat2
|
|
||||||
a feature
|
|
||||||
doc symbol=Alternate
|
doc symbol=Alternate
|
||||||
body=
|
body=
|
||||||
|
|
||||||
|
|
|
@ -130,26 +130,6 @@ Features
|
||||||
a feature
|
a feature
|
||||||
|
|
||||||
|
|
||||||
"SugaredUnion" (Object)
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
|
|
||||||
Members
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
"type"
|
|
||||||
One of "one", "two"
|
|
||||||
|
|
||||||
"data": "Variant1" when "type" is ""one""
|
|
||||||
"data": "Variant2" when "type" is ""two"" (**If: **"IFTWO")
|
|
||||||
|
|
||||||
Features
|
|
||||||
~~~~~~~~
|
|
||||||
|
|
||||||
"union-feat2"
|
|
||||||
a feature
|
|
||||||
|
|
||||||
|
|
||||||
"Alternate" (Alternate)
|
"Alternate" (Alternate)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
flat-union-base-union.json: In union 'TestUnion':
|
flat-union-base-union.json: In union 'TestUnion':
|
||||||
flat-union-base-union.json:14: 'base' requires a struct type, union type 'UnionBase' isn't
|
flat-union-base-union.json:17: 'base' requires a struct type, union type 'UnionBase' isn't
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
'data': { 'string': 'str' } }
|
'data': { 'string': 'str' } }
|
||||||
{ 'struct': 'TestTypeB',
|
{ 'struct': 'TestTypeB',
|
||||||
'data': { 'integer': 'int' } }
|
'data': { 'integer': 'int' } }
|
||||||
|
{ 'enum': 'Enum', 'data': [ 'kind1', 'kind2' ] }
|
||||||
{ 'union': 'UnionBase',
|
{ 'union': 'UnionBase',
|
||||||
|
'base': { 'type': 'Enum' },
|
||||||
|
'discriminator': 'type',
|
||||||
'data': { 'kind1': 'TestTypeA',
|
'data': { 'kind1': 'TestTypeA',
|
||||||
'kind2': 'TestTypeB' } }
|
'kind2': 'TestTypeB' } }
|
||||||
{ 'union': 'TestUnion',
|
{ 'union': 'TestUnion',
|
||||||
|
|
|
@ -192,14 +192,10 @@ schemas = [
|
||||||
'unclosed-string.json',
|
'unclosed-string.json',
|
||||||
'union-base-empty.json',
|
'union-base-empty.json',
|
||||||
'union-base-no-discriminator.json',
|
'union-base-no-discriminator.json',
|
||||||
'union-branch-case.json',
|
|
||||||
'union-branch-if-invalid.json',
|
'union-branch-if-invalid.json',
|
||||||
'union-branch-invalid-dict.json',
|
'union-branch-invalid-dict.json',
|
||||||
'union-clash-branches.json',
|
|
||||||
'union-empty.json',
|
|
||||||
'union-invalid-base.json',
|
'union-invalid-base.json',
|
||||||
'union-invalid-data.json',
|
'union-invalid-data.json',
|
||||||
'union-optional-branch.json',
|
|
||||||
'union-unknown.json',
|
'union-unknown.json',
|
||||||
'unknown-escape.json',
|
'unknown-escape.json',
|
||||||
'unknown-expr-key.json',
|
'unknown-expr-key.json',
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
union-branch-case.json: In union 'Uni':
|
|
||||||
union-branch-case.json:2: name of 'data' member 'Branch' must not use uppercase or '_'
|
|
|
@ -1,2 +0,0 @@
|
||||||
# Branch names should be 'lower-case'
|
|
||||||
{ 'union': 'Uni', 'data': { 'Branch': 'int' } }
|
|
|
@ -1,2 +1,2 @@
|
||||||
union-branch-invalid-dict.json: In union 'UnionInvalidBranch':
|
union-branch-invalid-dict.json: In union 'UnionInvalidBranch':
|
||||||
union-branch-invalid-dict.json:2: 'data' member 'integer' misses key 'type'
|
union-branch-invalid-dict.json:4: 'data' member 'integer' misses key 'type'
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
# Long form of member must have a value member 'type'
|
# Long form of member must have a value member 'type'
|
||||||
|
{ 'enum': 'TestEnum',
|
||||||
|
'data': [ 'integer', 's8' ] }
|
||||||
{ 'union': 'UnionInvalidBranch',
|
{ 'union': 'UnionInvalidBranch',
|
||||||
|
'base': { 'type': 'TestEnum' },
|
||||||
|
'discriminator': 'type',
|
||||||
'data': { 'integer': { 'if': 'foo'},
|
'data': { 'integer': { 'if': 'foo'},
|
||||||
's8': 'int8' } }
|
's8': 'int8' } }
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
union-clash-branches.json: In union 'TestUnion':
|
|
||||||
union-clash-branches.json:6: name of 'data' member 'a_b' must not use uppercase or '_'
|
|
|
@ -1,7 +0,0 @@
|
||||||
# Union branch name collision
|
|
||||||
# Naming rules make collision impossible (even with the pragma). If
|
|
||||||
# that wasn't the case, then we'd get collisions in generated C: two
|
|
||||||
# union members a_b, and two enum members TEST_UNION_A_B.
|
|
||||||
{ 'pragma': { 'member-name-exceptions': [ 'TestUnion' ] } }
|
|
||||||
{ 'union': 'TestUnion',
|
|
||||||
'data': { 'a-b': 'int', 'a_b': 'str' } }
|
|
|
@ -1,2 +0,0 @@
|
||||||
union-empty.json: In union 'Union':
|
|
||||||
union-empty.json:2: union has no branches
|
|
|
@ -1,2 +0,0 @@
|
||||||
# simple unions cannot be empty
|
|
||||||
{ 'union': 'Union', 'data': { } }
|
|
|
@ -1,2 +0,0 @@
|
||||||
union-optional-branch.json: In union 'Union':
|
|
||||||
union-optional-branch.json:2: 'data' member '*a' has an invalid name
|
|
|
@ -1,2 +0,0 @@
|
||||||
# union branches cannot be optional
|
|
||||||
{ 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } }
|
|
|
@ -1,2 +1,2 @@
|
||||||
union-unknown.json: In union 'Union':
|
union-unknown.json: In union 'Union':
|
||||||
union-unknown.json:2: union uses unknown type 'MissingType'
|
union-unknown.json:3: branch 'unknown' uses unknown type 'MissingType'
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
# we reject a union with unknown type in branch
|
# we reject a union with unknown type in branch
|
||||||
|
{ 'enum': 'Enum', 'data': [ 'unknown' ] }
|
||||||
{ 'union': 'Union',
|
{ 'union': 'Union',
|
||||||
'data': { 'unknown': ['MissingType'] } }
|
'base': { 'type': 'Enum' },
|
||||||
|
'discriminator': 'type',
|
||||||
|
'data': { 'unknown': 'MissingType' } }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue