
def test_implementation(code: str, purpose: str) -> bool:
    """Actually RUN the generated code to see if it works"""
    try:
        # Compile check
        compile(code, '<string>', 'exec')
        
        # Create test environment
        test_context = {'task': f'test_{purpose}', 'context': {}}
        
        # Try to execute (sandboxed)
        exec(code, test_context)
        
        return True
    except Exception as e:
        print(f"  ⚠️  Implementation failed test: {e}")
        return False
