feat(mcp): Add full functional parity for C/C++ tools
This commit is contained in:
@@ -86,3 +86,93 @@ def test_ts_cpp_get_code_outline_dispatch(tmp_path, mock_resolve):
|
||||
mock_instance.get_code_outline.assert_called_once()
|
||||
assert result and len(result) > 0
|
||||
assert "[Func] main (Lines 1-1)" in result
|
||||
|
||||
def test_ts_c_get_definition_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_c_get_definition via dispatch
|
||||
c_file = tmp_path / "test.c"
|
||||
c_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.get_definition.return_value = "void foo() {}"
|
||||
|
||||
result = dispatch("ts_c_get_definition", {"path": str(c_file), "name": "foo"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("c")
|
||||
mock_instance.get_definition.assert_called_once()
|
||||
assert "void foo() {}" in result
|
||||
|
||||
def test_ts_cpp_get_definition_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_cpp_get_definition via dispatch
|
||||
cpp_file = tmp_path / "test.cpp"
|
||||
cpp_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.get_definition.return_value = "void foo() {}"
|
||||
|
||||
result = dispatch("ts_cpp_get_definition", {"path": str(cpp_file), "name": "foo"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("cpp")
|
||||
mock_instance.get_definition.assert_called_once()
|
||||
assert "void foo() {}" in result
|
||||
|
||||
def test_ts_c_get_signature_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_c_get_signature via dispatch
|
||||
c_file = tmp_path / "test.c"
|
||||
c_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.get_signature.return_value = "void foo()"
|
||||
|
||||
result = dispatch("ts_c_get_signature", {"path": str(c_file), "name": "foo"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("c")
|
||||
mock_instance.get_signature.assert_called_once()
|
||||
assert "void foo()" in result
|
||||
|
||||
def test_ts_cpp_get_signature_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_cpp_get_signature via dispatch
|
||||
cpp_file = tmp_path / "test.cpp"
|
||||
cpp_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.get_signature.return_value = "void foo()"
|
||||
|
||||
result = dispatch("ts_cpp_get_signature", {"path": str(cpp_file), "name": "foo"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("cpp")
|
||||
mock_instance.get_signature.assert_called_once()
|
||||
assert "void foo()" in result
|
||||
|
||||
def test_ts_c_update_definition_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_c_update_definition via dispatch
|
||||
c_file = tmp_path / "test.c"
|
||||
c_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.update_definition.return_value = "void foo() { return; }"
|
||||
|
||||
result = dispatch("ts_c_update_definition", {"path": str(c_file), "name": "foo", "new_content": "void foo() { return; }"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("c")
|
||||
mock_instance.update_definition.assert_called_once()
|
||||
assert "Successfully updated" in result
|
||||
|
||||
def test_ts_cpp_update_definition_dispatch(tmp_path, mock_resolve):
|
||||
# Verify ts_cpp_update_definition via dispatch
|
||||
cpp_file = tmp_path / "test.cpp"
|
||||
cpp_file.write_text("void foo() {}")
|
||||
|
||||
with patch("src.file_cache.ASTParser") as mock_parser_cls:
|
||||
mock_instance = mock_parser_cls.return_value
|
||||
mock_instance.update_definition.return_value = "void foo() { return; }"
|
||||
|
||||
result = dispatch("ts_cpp_update_definition", {"path": str(cpp_file), "name": "foo", "new_content": "void foo() { return; }"})
|
||||
|
||||
mock_parser_cls.assert_called_once_with("cpp")
|
||||
mock_instance.update_definition.assert_called_once()
|
||||
assert "Successfully updated" in result
|
||||
|
||||
Reference in New Issue
Block a user