feat(mma): Implement Deep AST-Driven Context Pruning and mark track complete
This commit is contained in:
@@ -63,3 +63,60 @@ def hot_func():
|
||||
assert 'print("keep me too")' in curated
|
||||
assert '@core_logic' in curated
|
||||
assert '# [HOT]' in curated
|
||||
|
||||
def test_ast_parser_get_targeted_view() -> None:
|
||||
"""Verify get_targeted_view includes targeted functions and dependencies."""
|
||||
parser = ASTParser(language="python")
|
||||
code = '''
|
||||
import sys
|
||||
|
||||
def dep2():
|
||||
"""Dep 2"""
|
||||
print("dep2")
|
||||
|
||||
def dep1():
|
||||
"""Dep 1"""
|
||||
dep2()
|
||||
|
||||
def targeted():
|
||||
"""Targeted"""
|
||||
dep1()
|
||||
|
||||
def unrelated():
|
||||
"""Unrelated"""
|
||||
print("unrelated")
|
||||
|
||||
class MyClass:
|
||||
def method1(self):
|
||||
"""Method 1"""
|
||||
targeted()
|
||||
def method2(self):
|
||||
"""Method 2"""
|
||||
pass
|
||||
'''
|
||||
# Depth 0: targeted
|
||||
# Depth 1: dep1 (called by targeted)
|
||||
# Depth 2: dep2 (called by dep1)
|
||||
view = parser.get_targeted_view(code, ["targeted"])
|
||||
assert 'def targeted():' in view
|
||||
assert '"""Targeted"""' in view
|
||||
assert 'def dep1():' in view
|
||||
assert '"""Dep 1"""' in view
|
||||
assert 'def dep2():' in view
|
||||
assert '"""Dep 2"""' in view
|
||||
assert 'def unrelated():' not in view
|
||||
assert 'class MyClass:' not in view
|
||||
assert 'import sys' in view
|
||||
|
||||
# Test depth limit
|
||||
# Depth 0: MyClass.method1
|
||||
# Depth 1: targeted (called by method1)
|
||||
# Depth 2: dep1 (called by targeted)
|
||||
# Depth 3: dep2 (called by dep1) -> should be elided
|
||||
view2 = parser.get_targeted_view(code, ["MyClass.method1"])
|
||||
assert 'class MyClass:' in view2
|
||||
assert 'def method1(self):' in view2
|
||||
assert 'def targeted():' in view2
|
||||
assert 'def dep1():' in view2
|
||||
assert 'def dep2():' not in view2
|
||||
assert 'def method2(self):' not in view2
|
||||
|
||||
Reference in New Issue
Block a user