Team Ai
Apppublic

SpinachLove/code-rag-assistant

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
test_code_analyze.py24 linesDownload Raw Back to backend
1from llm.code_analyzer import analyze_code, solve_code_error
2
3if __name__ == "__main__":
4    print("===== 开始代码分析模块测试 =====")
5    
6    # 测试代码分析功能
7    print("\n1. 测试代码分析功能...")
8    test_code = """
9def calculate_sum(n):
10    sum = 0
11    for i in range(n):
12        sum += i
13    return sum
14
15print(calculate_sum(10))
16    """.strip()  # 用strip()去掉首尾多余的空行
17    
18    analyze_result = analyze_code(test_code, "Python")
19    print("代码分析结果:")
20    print("-" * 50)
21    print(analyze_result)
22    print("-" * 50)
23
24    print("\n===== 代码分析模块测试完成 =====")