object-introspection/test/integration/arrays.toml
Jake Hillion 3871d92abb collapse TreeBuilderV2 features
Summary:

Currently there are two features between CodeGen v2 (TypeGraph) and TreeBuilder
v2. These are TypedDataSegment and TreeBuilderTypeChecking. Each of these
features currently has a full set of tests run in the CI and each have specific
exclusions.

Collapse these features into TreeBuilder v2. This allows for significantly
simplified testing as any OIL tests run under TreeBuilder v2 and any OID tests
run under TreeBuilder v1.

The reasoning behind this is I no longer intend to partially roll out this
feature. Full TreeBuilder v2 applies different conditions to containers than
the intermediate states, and writing these only to have them never deployed is
a waste of time.

Test Plan:
- it builds
- CI
2023-11-13 19:43:03 +00:00

120 lines
4.0 KiB
TOML

definitions = '''
struct Foo10 {
int arr[10];
};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wzero-length-array"
struct Foo0 {
int arr[0];
};
using ZeroLengthIntArray = int[0];
#pragma clang diagnostic pop
struct MultiDim {
int arr[2][3];
};
'''
[cases]
[cases.member_int10]
param_types = ["const Foo10&"]
setup = "return {};"
expect_json = '''[{
"staticSize":40,
"dynamicSize":0,
"members":[{
"staticSize":40,
"dynamicSize":0,
"length":10,
"capacity":10,
"elementStaticSize":4
}]}]'''
expect_json_v2 = '''[{
"staticSize":40,
"exclusiveSize":0,
"members":[{
"staticSize":40,
"exclusiveSize":0,
"length":10,
"capacity":10
}]}]'''
[cases.member_int0]
oil_skip = 'zero length arrays fail codegen v2' # https://github.com/facebookexperimental/object-introspection/issues/295
# WARNING: zero-length arrays are handled differently to non-empty arrays.
# They end up not being treated as containers. This should probably change
# in the future.
param_types = ["const Foo0&"]
setup = "return {};"
expect_json = '''[{
"staticSize":0,
"dynamicSize":0,
"members":[{
"staticSize":0,
"dynamicSize":0
}]}]'''
expect_json_v2 = '''[{
"staticSize":1,
"exclusiveSize":1,
"members":[{
"staticSize":0,
"exclusiveSize":0
}]}]'''
[cases.multidim_legacy] # Test for legacy behaviour. Remove with OICodeGen
oil_disable = 'oil only runs on codegen v2'
cli_options = ["-Ftype-graph", "-Ftree-builder-v2"]
param_types = ["const MultiDim&"]
setup = "return {};"
expect_json = '''[{
"staticSize":24,
"dynamicSize":0,
"members":[{
"staticSize":24,
"dynamicSize":0,
"length":6,
"capacity":6,
"elementStaticSize":4
}]}]'''
[cases.multidim]
cli_options = ["-ftype-graph"]
param_types = ["const MultiDim&"]
setup = "return {};"
expect_json = '''[
{"staticSize":24, "dynamicSize":0, "exclusiveSize":0, "members":[
{"staticSize":24, "dynamicSize":0, "exclusiveSize":0, "length":2, "capacity":2, "elementStaticSize":12, "members":[
{"staticSize":12, "dynamicSize":0, "exclusiveSize":12, "length":3, "capacity":3, "elementStaticSize":4},
{"staticSize":12, "dynamicSize":0, "exclusiveSize":12, "length":3, "capacity":3, "elementStaticSize":4}]
}]}]'''
expect_json_v2 = '''[
{"staticSize":24, "exclusiveSize":0, "members":[
{"staticSize":24, "exclusiveSize":0, "length":2, "capacity":2, "members":[
{"staticSize":12, "exclusiveSize":0, "length":3, "capacity":3},
{"staticSize":12, "exclusiveSize":0, "length":3, "capacity":3}]
}]}]'''
[cases.direct_int10]
skip = "Direct array arguments don't work"
param_types = ["int[10]"]
setup = "return {};"
expect_json = '[{"staticSize":40, "dynamicSize":0, "length":10, "capacity":10, "elementStaticSize":4}]'
[cases.direct_int0]
skip = "Direct array arguments don't work"
# WARNING: zero-length arrays are handled differently to non-empty arrays.
# They end up not being treated as containers. This should probably change
# in the future.
param_types = ["ZeroLengthIntArray"]
setup = "return {};"
expect_json = '[{"staticSize":0, "dynamicSize":0}]'
[cases.ref_int10]
skip = "CodeGen bug with array reference arguments"
param_types = ["const int(&)[10]"]
setup = "return {};"
expect_json = '[{"staticSize":40, "dynamicSize":0, "length":10, "capacity":10, "elementStaticSize":4}]'
[cases.ref_int0]
skip = "CodeGen bug with array reference arguments"
# WARNING: zero-length arrays are handled differently to non-empty arrays.
# They end up not being treated as containers. This should probably change
# in the future.
param_types = ["const ZeroLengthIntArray&"]
setup = "return {};"
expect_json = '[{"staticSize":0, "dynamicSize":0}]'