object-introspection/test/integration/pointers_incomplete.toml
Jake Hillion 358b4e9505 add oil_disable test option
The `oil_skip` test option was added for tests that don't work under OIL
but do work under OID. However, we now have two classes of `oil_skip`ped
tests: those that could be fixed, and those that will never work.
Increase clarity by not generating the tests which do not make sense at
all, leaving us with a cleaner set of skipped (and fixable) tests.
2023-01-04 17:56:37 +00:00

115 lines
3.8 KiB
TOML

includes = ["memory", "optional"]
definitions = '''
struct IncompleteType;
struct IncompleteTypeContainer {
IncompleteType *ptrundef;
// std::unique_ptr<IncompleteType> unundef; // std::unique_ptr requires its template param to have a size
char __makePad1;
std::shared_ptr<IncompleteType> shundef;
char __makePad2;
std::optional<std::shared_ptr<IncompleteType>> shoptundef;
char __makePad3;
std::optional<IncompleteType *> optundef;
};
void incomplete_type_deleter(IncompleteType *ptr) {
::operator delete(ptr);
}
'''
[cases]
[cases.raw]
skip = "codegen fails on this"
param_types = ["IncompleteType*"]
setup = "return static_cast<IncompleteType*>(::operator new(5));"
cli_options = ["--chase-raw-pointers"]
expect_json = '''[{
"typeName": "IncompleteType *",
"staticSize": 8,
"dynamicSize": 0,
"NOT": {"pointer": 0},
"NOT": "members"
}]'''
[cases.raw_no_follow]
skip = "codegen fails on this"
param_types = ["IncompleteType*"]
setup = "return static_cast<IncompleteType*>(::operator new(5));"
expect_json = '''[{
"typeName": "IncompleteType *",
"staticSize": 8,
"dynamicSize": 0,
"NOT": {"pointer": 0},
"NOT": "members"
}]'''
[cases.raw_null]
skip = "codegen fails on this"
param_types = ["IncompleteType*"]
setup = "return nullptr;"
expect_json = '''[{
"typeName": "IncompleteType *",
"staticSize": 8,
"dynamicSize": 0,
"pointer": 0,
"NOT": "members"
}]'''
[cases.unique_ptr]
param_types = ["const std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>&"]
setup = '''
auto raw_ptr = static_cast<IncompleteType*>(::operator new(5));
return std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>(
raw_ptr, &incomplete_type_deleter);
'''
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
[cases.unique_ptr_null]
param_types = ["const std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>&"]
setup = '''
return std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>(
nullptr, &incomplete_type_deleter);
'''
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
[cases.shared_ptr]
param_types = ["const std::shared_ptr<IncompleteType>&"]
setup = '''
auto raw_ptr = static_cast<IncompleteType*>(::operator new(5));
return std::shared_ptr<IncompleteType>(raw_ptr , &incomplete_type_deleter);
'''
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
[cases.shared_ptr_null]
param_types = ["const std::shared_ptr<IncompleteType>"]
setup = "return nullptr;"
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
[cases.containing_struct]
oil_disable = "oil can't chase raw pointers safely"
param_types = ["const IncompleteTypeContainer&"]
setup = "return IncompleteTypeContainer{};"
cli_options = ["--chase-raw-pointers"]
expect_json = '''[{
"staticSize": 88,
"dynamicSize": 0,
"paddingSavingsSize": 21,
"members": [
{ "name": "ptrundef", "staticSize": 8, "dynamicSize": 0 },
{ "name": "__makePad1", "staticSize": 1, "dynamicSize": 0 },
{ "name": "shundef", "staticSize": 16, "dynamicSize": 0 },
{ "name": "__makePad2", "staticSize": 1, "dynamicSize": 0 },
{ "name": "shoptundef",
"staticSize": 24,
"dynamicSize": 0,
"length": 0,
"capacity": 1,
"elementStaticSize": 16
},
{ "name": "__makePad3", "staticSize": 1, "dynamicSize": 0 },
{ "name": "optundef",
"staticSize": 16,
"dynamicSize": 0,
"length": 0,
"capacity": 1,
"elementStaticSize": 8
}
]
}]'''