Skip to content

Commit

Permalink
Test the entire public API of hierarchies
Browse files Browse the repository at this point in the history
  • Loading branch information
bstaletic committed Jun 13, 2024
1 parent d51c886 commit 4342440
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 76 deletions.
79 changes: 52 additions & 27 deletions ycmd/tests/clangd/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,22 +1329,31 @@ def test_Subcommands_SupertypeHierarchy( self, app ):
for location, response, code in [
[ ( filepath, 16, 8 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 13, 8 )
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 12, 8 )
) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 13, 8 )
),
'name': 'B1',
'kind': 'Struct'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 12, 8 )
),
'name': 'B0',
'kind': 'Struct'
} ),
),
requests.codes.ok ],
[ ( filepath, 13, 8 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 12, 8 )
) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 12, 8 )
),
'name': 'B0',
'kind': 'Struct'
} ),
),
requests.codes.ok ],
[ ( filepath, 12, 8 ),
Expand All @@ -1361,18 +1370,28 @@ def test_Subcommands_SubtypeHierarchy( self, app ):
for location, response, code in [
[ ( filepath, 12, 8 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 13, 8 )
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 15, 8 )
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 16, 8 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 13, 8 )
),
'name': 'B1',
'kind': 'Struct'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 15, 8 )
),
'name': 'D0',
'kind': 'Struct'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 16, 8 )
),
'name': 'D1',
'kind': 'Struct'
} ),
),
requests.codes.ok ],
[ ( filepath, 13, 8 ),
contains_inanyorder(
Expand All @@ -1399,19 +1418,25 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
'locations': contains_exactly(
LocationMatcher( filepath, 4, 12 ),
LocationMatcher( filepath, 4, 18 ) ),
'root_location': LocationMatcher( filepath, 3, 5 )
'root_location': LocationMatcher( filepath, 3, 5 ),
'name': 'g',
'kind': 'Function'
} ),
has_entries( {
'locations': contains_exactly( LocationMatcher( filepath, 9, 12 ) ),
'root_location': LocationMatcher( filepath, 7, 5 )
'root_location': LocationMatcher( filepath, 7, 5 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
[ ( filepath, 3, 5 ),
contains_inanyorder(
has_entries( {
'locations': contains_exactly( LocationMatcher( filepath, 8, 13 ) ),
'root_location': LocationMatcher( filepath, 7, 5 )
'root_location': LocationMatcher( filepath, 7, 5 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
Expand Down
46 changes: 30 additions & 16 deletions ycmd/tests/go/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,22 +567,30 @@ def test_Subcommands_OutgoingCallHierarchy( self, app ):
for location, response, code in [
[ ( filepath, 9, 6 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 10, 13 ),
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 11, 12 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 13 ) ),
'kind': 'Function',
'name': 'g'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 12 ) ),
'kind': 'Function',
'name': 'f'
} )
),
requests.codes.ok ],
[ ( filepath, 6, 6 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 7, 12 ),
LocationMatcher( filepath, 7, 18 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 7, 12 ),
LocationMatcher( filepath, 7, 18 ) ),
'kind': 'Function',
'name': 'f'
} ),
),
requests.codes.ok ],
[ ( filepath, 3, 6 ),
ErrorMatcher( RuntimeError, 'No outgoing calls found.' ),
Expand All @@ -602,12 +610,16 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
'locations': contains_exactly(
LocationMatcher( filepath, 7, 12 ),
LocationMatcher( filepath, 7, 18 ) ),
'root_location': LocationMatcher( filepath, 6, 6 )
'root_location': LocationMatcher( filepath, 6, 6 ),
'name': 'g',
'kind': 'Function'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 12 ) ),
'root_location': LocationMatcher( filepath, 9, 6 )
'root_location': LocationMatcher( filepath, 9, 6 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
Expand All @@ -616,7 +628,9 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 13 ) ),
'root_location': LocationMatcher( filepath, 9, 6 )
'root_location': LocationMatcher( filepath, 9, 6 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
Expand Down
39 changes: 22 additions & 17 deletions ycmd/tests/rust/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,19 @@ def test_Subcommands_OutgoingCallHierarchy( self, app ):
for location, response, code in [
[ ( filepath, 9, 4 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 10, 13 ),
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 11, 5 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 13 ) ),
'kind': 'Function',
'name': 'g'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 5 ) ),
'kind': 'Function',
'name': 'f'
} )
),
requests.codes.ok ],
[ ( filepath, 5, 4 ),
contains_inanyorder(
Expand Down Expand Up @@ -633,16 +638,16 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
'locations': contains_exactly(
LocationMatcher( filepath, 6, 5 ),
LocationMatcher( filepath, 6, 11 ) ),
# rust-analyzer always returns column 1 for root_location,
# which is useless for us... unfortunately.
'root_location': LocationMatcher( filepath, 5, 4 )
'root_location': LocationMatcher( filepath, 5, 4 ),
'name': 'g',
'kind': 'Function'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 5 ) ),
# rust-analyzer always returns column 1 for root_location,
# which is useless for us... unfortunately.
'root_location': LocationMatcher( filepath, 9, 4 )
'root_location': LocationMatcher( filepath, 9, 4 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
Expand All @@ -651,9 +656,9 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 13 ) ),
# rust-analyzer always returns column 1 for root_location,
# which is useless for us... unfortunately.
'root_location': LocationMatcher( filepath, 9, 4 )
'root_location': LocationMatcher( filepath, 9, 4 ),
'name': 'h',
'kind': 'Function'
} )
),
requests.codes.ok ],
Expand Down
46 changes: 30 additions & 16 deletions ycmd/tests/typescript/subcommands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,22 +1205,30 @@ def test_Subcommands_OutgoingCallHierarchy( self, app ):
for location, response, code in [
[ ( filepath, 9, 10 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 10, 11 ),
) ),
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 11, 14 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 11 ) ),
'kind': 'function',
'name': 'g'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 14 ) ),
'kind': 'function',
'name': 'f'
} )
),
requests.codes.ok ],
[ ( filepath, 5, 10 ),
contains_inanyorder(
has_entry( 'locations',
contains_exactly(
LocationMatcher( filepath, 6, 10 ),
LocationMatcher( filepath, 6, 16 )
) ) ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 6, 10 ),
LocationMatcher( filepath, 6, 16 ) ),
'kind': 'function',
'name': 'f'
} ),
),
requests.codes.ok ],
[ ( filepath, 1, 10 ),
ErrorMatcher( RuntimeError, 'No outgoing calls found.' ),
Expand All @@ -1240,12 +1248,16 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
'locations': contains_exactly(
LocationMatcher( filepath, 6, 10 ),
LocationMatcher( filepath, 6, 16 ) ),
'root_location': LocationMatcher( filepath, 5, 10 )
'root_location': LocationMatcher( filepath, 5, 10 ),
'name': 'g',
'kind': 'function'
} ),
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 11, 14 ) ),
'root_location': LocationMatcher( filepath, 9, 10 )
'root_location': LocationMatcher( filepath, 9, 10 ),
'name': 'h',
'kind': 'function'
} )
),
requests.codes.ok ],
Expand All @@ -1254,7 +1266,9 @@ def test_Subcommands_IncomingCallHierarchy( self, app ):
has_entries( {
'locations': contains_exactly(
LocationMatcher( filepath, 10, 11 ) ),
'root_location': LocationMatcher( filepath, 9, 10 )
'root_location': LocationMatcher( filepath, 9, 10 ),
'name': 'h',
'kind': 'function'
} )
),
requests.codes.ok ],
Expand Down

0 comments on commit 4342440

Please sign in to comment.