feat(mma): Implement AST Skeleton View generator using tree-sitter
This commit is contained in:
40
tests/test_mma_skeleton.py
Normal file
40
tests/test_mma_skeleton.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
from scripts.mma_exec import generate_skeleton
|
||||
|
||||
def test_generate_skeleton():
|
||||
sample_code = '''
|
||||
class Calculator:
|
||||
"""Performs basic math operations."""
|
||||
|
||||
def add(self, a: int, b: int) -> int:
|
||||
"""Adds two numbers."""
|
||||
result = a + b
|
||||
return result
|
||||
|
||||
def log_message(msg):
|
||||
timestamp = "2026-02-25"
|
||||
print(f"[{timestamp}] {msg}")
|
||||
'''
|
||||
|
||||
skeleton = generate_skeleton(sample_code)
|
||||
|
||||
# Check that signatures are preserved
|
||||
assert "class Calculator:" in skeleton
|
||||
assert "def add(self, a: int, b: int) -> int:" in skeleton
|
||||
assert "def log_message(msg):" in skeleton
|
||||
|
||||
# Check that docstrings are preserved
|
||||
assert '"""Performs basic math operations."""' in skeleton
|
||||
assert '"""Adds two numbers."""' in skeleton
|
||||
|
||||
# Check that implementation details are removed
|
||||
assert "result = a + b" not in skeleton
|
||||
assert "return result" not in skeleton
|
||||
assert "timestamp =" not in skeleton
|
||||
assert "print(" not in skeleton
|
||||
|
||||
# Check that bodies are replaced with ellipsis
|
||||
assert "..." in skeleton
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__])
|
||||
Reference in New Issue
Block a user