mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-10 05:26:56 +00:00
6b780add4a
With a recent Thrift update, we now must also define a destructor for this type.
86 lines
2.7 KiB
TOML
86 lines
2.7 KiB
TOML
# TODO: The dynamic union tests should be updated when tagged union support is in:
|
|
# https://github.com/facebookexperimental/object-introspection/issues/234
|
|
thrift_definitions = '''
|
|
union StaticUnion {
|
|
1: i32 a;
|
|
2: i32 b;
|
|
3: i32 c;
|
|
}
|
|
|
|
union DynamicUnion {
|
|
1: i32 n;
|
|
2: list<i32> vec;
|
|
}
|
|
'''
|
|
raw_definitions = '''
|
|
namespace cpp2 {
|
|
void StaticUnion::__fbthrift_clear() {}
|
|
void DynamicUnion::__fbthrift_clear() {}
|
|
DynamicUnion::~DynamicUnion() {}
|
|
}
|
|
'''
|
|
|
|
[cases]
|
|
[cases.static]
|
|
param_types = ["const cpp2::StaticUnion&"]
|
|
setup = '''
|
|
cpp2::StaticUnion ret;
|
|
return ret;
|
|
'''
|
|
expect_json = '''[{
|
|
"staticSize":8,
|
|
"dynamicSize":0,
|
|
"members":[
|
|
{"typeName":"storage_type", "name":"value_", "staticSize":4},
|
|
{"typeName":"underlying_type_t<cpp2::StaticUnion::Type>", "name":"type_", "staticSize":4}
|
|
]}]'''
|
|
expect_json_v2 = '''[{
|
|
"staticSize":8,
|
|
"exclusiveSize":0,
|
|
"members":[
|
|
{"typeNames":["storage_type"], "name":"value_", "staticSize":4, "exclusiveSize":4},
|
|
{"typeNames":["underlying_type_t<cpp2::StaticUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
|
|
]}]'''
|
|
[cases.dynamic_int]
|
|
param_types = ["const cpp2::DynamicUnion&"]
|
|
setup = '''
|
|
cpp2::DynamicUnion ret;
|
|
ret.set_n(123);
|
|
return ret;
|
|
'''
|
|
expect_json = '''[{
|
|
"staticSize":32,
|
|
"dynamicSize":0,
|
|
"members":[
|
|
{"typeName":"storage_type", "name":"value_", "staticSize":24},
|
|
{"typeName":"underlying_type_t<cpp2::DynamicUnion::Type>", "name":"type_", "staticSize":4}
|
|
]}]'''
|
|
expect_json_v2 = '''[{
|
|
"staticSize":32,
|
|
"exclusiveSize":4,
|
|
"members":[
|
|
{"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24},
|
|
{"typeNames":["underlying_type_t<cpp2::DynamicUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
|
|
]}]'''
|
|
[cases.dynamic_vec]
|
|
param_types = ["const cpp2::DynamicUnion&"]
|
|
setup = '''
|
|
cpp2::DynamicUnion ret;
|
|
ret.set_vec({1,2,3});
|
|
return ret;
|
|
'''
|
|
expect_json = '''[{
|
|
"staticSize":32,
|
|
"dynamicSize":0,
|
|
"members":[
|
|
{"typeName":"storage_type", "name":"value_", "staticSize":24},
|
|
{"typeName":"underlying_type_t<cpp2::DynamicUnion::Type>", "name":"type_", "staticSize":4}
|
|
]}]'''
|
|
expect_json_v2 = '''[{
|
|
"staticSize":32,
|
|
"exclusiveSize":4,
|
|
"members":[
|
|
{"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24},
|
|
{"typeNames":["underlying_type_t<cpp2::DynamicUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
|
|
]}]'''
|