mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
4975b6e9fa
Previously we tested different feature flags by using the `cli_options` field in the test `.toml`. This works for OID but doesn't work for JIT OIL and won't work for AoT OIL when those tests get added. This change adds a new higher level `features` field to the test `.toml` which adds the features to the config file as a prefix. This works with all methods of generation. Change the existing `cli_options` features to `features` except for where they're testing something specific. Enable tests that were previously disabled for OIL but only didn't work because of not being able to enable features. Change pointer tests that are currently broken for OIL from `oil_disable` to `oil_skip` - they can work, but codegen is broken for them at the minute. Test plan: - CI - `make test` is no worse
249 lines
8.7 KiB
TOML
249 lines
8.7 KiB
TOML
includes = ["vector"]
|
|
definitions = '''
|
|
class Root {
|
|
public:
|
|
virtual ~Root() = default;
|
|
virtual void myfunc() {}
|
|
int int_root;
|
|
};
|
|
|
|
class Middle1 : public Root {
|
|
public:
|
|
virtual ~Middle1() = default;
|
|
virtual void myfunc() override {}
|
|
std::vector<int> vec_middle1;
|
|
};
|
|
|
|
class Middle2 : public Root {
|
|
public:
|
|
virtual ~Middle2() = default;
|
|
virtual void myfunc() override {}
|
|
std::vector<int> vec_middle2;
|
|
};
|
|
|
|
class Child : public Middle1, public Middle2 {
|
|
public:
|
|
virtual ~Child() = default;
|
|
virtual void myfunc() override {}
|
|
int int_child;
|
|
};
|
|
'''
|
|
[cases]
|
|
[cases.root_as_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Root&"]
|
|
arg_types = ["Root"]
|
|
setup = "return {};"
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Root",
|
|
"staticSize":16,
|
|
"dynamicSize":0,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|
|
|
|
[cases.middle1_as_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Root&"]
|
|
arg_types = ["Middle1"]
|
|
setup = '''
|
|
Middle1 m;
|
|
m.vec_middle1 = {1,2,3};
|
|
return m;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Middle1",
|
|
"staticSize":40,
|
|
"dynamicSize":12,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}
|
|
]}]'''
|
|
[cases.middle1_as_middle1]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Middle1&"]
|
|
arg_types = ["ns_inheritance_polymorphic_diamond::Middle1"]
|
|
setup = '''
|
|
Middle1 m;
|
|
m.vec_middle1 = {1,2,3};
|
|
return m;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Middle1",
|
|
"staticSize":40,
|
|
"dynamicSize":12,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}
|
|
]}]'''
|
|
|
|
[cases.middle2_as_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Root&"]
|
|
arg_types = ["Middle2"]
|
|
setup = '''
|
|
Middle2 m;
|
|
m.vec_middle2 = {4,5};
|
|
return m;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Middle2",
|
|
"staticSize":40,
|
|
"dynamicSize":8,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4}
|
|
]}]'''
|
|
[cases.middle2_as_middle2]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Middle2&"]
|
|
arg_types = ["Middle2"]
|
|
setup = '''
|
|
Middle2 m;
|
|
m.vec_middle2 = {4,5};
|
|
return m;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Middle2",
|
|
"staticSize":40,
|
|
"dynamicSize":8,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4}
|
|
]}]'''
|
|
|
|
[cases.child_as_middle1_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
# We need to explicitly cast from Child to Middle1 before going to root to
|
|
# resolve the diamond problem
|
|
param_types = ["const Root&"]
|
|
arg_types = ["Middle1&"]
|
|
setup = '''
|
|
auto c = new Child{};
|
|
c->vec_middle1 = {1,2,3};
|
|
c->vec_middle2 = {4,5};
|
|
return static_cast<Middle1&>(*c);
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Child",
|
|
"staticSize":88,
|
|
"dynamicSize":20,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|
|
[cases.child_as_middle2_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
# We need to explicitly cast from Child to Middle2 before going to root to
|
|
# resolve the diamond problem
|
|
param_types = ["const Root&"]
|
|
arg_types = ["Middle2&"]
|
|
setup = '''
|
|
auto c = new Child{};
|
|
c->vec_middle1 = {1,2,3};
|
|
c->vec_middle2 = {4,5};
|
|
return static_cast<Middle2&>(*c);
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Child",
|
|
"staticSize":88,
|
|
"dynamicSize":20,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|
|
[cases.child_as_middle1]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Middle1&"]
|
|
arg_types = ["Child"]
|
|
setup = '''
|
|
Child c;
|
|
c.vec_middle1 = {1,2,3};
|
|
c.vec_middle2 = {4,5};
|
|
return c;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Child",
|
|
"staticSize":88,
|
|
"dynamicSize":20,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|
|
[cases.child_as_middle2]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Middle2&"]
|
|
arg_types = ["Child"]
|
|
setup = '''
|
|
Child c;
|
|
c.vec_middle1 = {1,2,3};
|
|
c.vec_middle2 = {4,5};
|
|
return c;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Child",
|
|
"staticSize":88,
|
|
"dynamicSize":20,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|
|
[cases.child_as_child]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
features = ["polymorphic-inheritance"]
|
|
param_types = ["const Child&"]
|
|
arg_types = ["Child"]
|
|
setup = '''
|
|
Child c;
|
|
c.vec_middle1 = {1,2,3};
|
|
c.vec_middle2 = {4,5};
|
|
return c;
|
|
'''
|
|
expect_json = '''[{
|
|
"typeName":"ns_inheritance_polymorphic_diamond::Child",
|
|
"staticSize":88,
|
|
"dynamicSize":20,
|
|
"members":[
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":8, "dynamicSize":0},
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
]}]'''
|