diff --git a/lsp-server/test/test_ast/test.sh b/lsp-server/test/test_ast/test.sh index 50da13b..253d296 100644 --- a/lsp-server/test/test_ast/test.sh +++ b/lsp-server/test/test_ast/test.sh @@ -21,14 +21,13 @@ find_test_ast() { if [ ! -d "$search_dir" ]; then return 1 fi - find "$search_dir" -type f -name test_ast -path "*/test/test_ast/*" -print -quit 2>/dev/null + find "$search_dir" -type f -name test_ast \( -path "*/test/test_ast" -o -path "*/test/test_ast/*" \) -print -quit 2>/dev/null } -TEST_AST="${TEST_AST_OVERRIDE:-$(find_test_ast "$REPO_ROOT/build/$BUILD_PRESET")}" - # 需要测试的目录列表(可以自行添加) DIRECTORIES=( "$REPO_ROOT/test/test_tree_sitter/test" + "$HOME/windows_share/tsf" # "./another_directory" ) @@ -86,6 +85,9 @@ while [[ $# -gt 0 ]]; do esac done +# 解析参数后再定位 test_ast +TEST_AST="${TEST_AST_OVERRIDE:-$(find_test_ast "$REPO_ROOT/build/$BUILD_PRESET")}" + # 检查 test_ast 是否存在 if [ -z "$TEST_AST" ] || [ ! -f "$TEST_AST" ]; then echo -e "${RED}错误: 找不到 test_ast 可执行文件${NC}" diff --git a/lsp-server/test/test_symbol/test.sh b/lsp-server/test/test_symbol/test.sh index c10c90d..892c098 100644 --- a/lsp-server/test/test_symbol/test.sh +++ b/lsp-server/test/test_symbol/test.sh @@ -19,16 +19,16 @@ find_test_symbol() { return 1 fi - find "$search_dir" -type f -name test_symbol -path "*/test/test_symbol/*" -print -quit 2>/dev/null + find "$search_dir" -type f -name test_symbol \( -path "*/test/test_symbol" -o -path "*/test/test_symbol/*" \) -print -quit 2>/dev/null } BUILD_PRESET=${BUILD_PRESET:-clang-ninja} -TEST_SYMBOL="${TEST_SYMBOL_OVERRIDE:-$(find "$REPO_ROOT/build/$BUILD_PRESET" -type f -name test_symbol -path "*/test/test_symbol/*" -print -quit 2>/dev/null)}" IGNORES=("IDS_AuditExpr.tsf") # 需要测试的目录列表(可以自行添加) DIRECTORIES=( "$REPO_ROOT/test/test_tree_sitter/test" + "$HOME/windows_share/tsf" # "./another_directory" ) @@ -86,6 +86,9 @@ while [[ $# -gt 0 ]]; do esac done +# 解析参数后再定位 test_symbol +TEST_SYMBOL="${TEST_SYMBOL_OVERRIDE:-$(find_test_symbol "$REPO_ROOT/build/$BUILD_PRESET")}" + # 检查 test_symbol 是否存在 if [ -z "$TEST_SYMBOL" ] || [ ! -f "$TEST_SYMBOL" ]; then echo -e "${RED}错误: 找不到 test_symbol 可执行文件${NC}" diff --git a/lsp-server/test/test_tree_sitter/test/test_tsf.sh b/lsp-server/test/test_tree_sitter/test/test_tsf.sh index 3bb2322..e7f543a 100644 --- a/lsp-server/test/test_tree_sitter/test/test_tsf.sh +++ b/lsp-server/test/test_tree_sitter/test/test_tsf.sh @@ -708,6 +708,14 @@ else echo " ❌ if语句解析失败" fi +echo "12.1.1 test if without semicolon before else" +echo 'function test(); begin if a > b then x := a else x := b; end;' | tree-sitter parse > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo " ✅ if (no semicolon) parsed" +else + echo " ❌ if (no semicolon) parse failed" +fi + echo "12.2 测试复杂if语句" cat > temp_if_test.tsf << 'EOF' function test(); @@ -763,6 +771,14 @@ else echo " ❌ for循环解析失败" fi +echo "12.4.1 test for body without semicolon" +echo 'function test(); begin for i:=0 to 10 do x += 1 end;' | tree-sitter parse > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo " ✅ for (no semicolon) parsed" +else + echo " ❌ for (no semicolon) parse failed" +fi + echo "12.5 测试for...to循环" echo 'function test(); begin for i:=0 to 10 do x := i; end;' | tree-sitter parse > /dev/null 2>&1 if [ $? -eq 0 ]; then @@ -779,6 +795,14 @@ else echo " ❌ while循环解析失败" fi +echo "12.6.1 test while body without semicolon" +echo 'function test(); begin while x > 0 do x := x - 1 end;' | tree-sitter parse > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo " ✅ while (no semicolon) parsed" +else + echo " ❌ while (no semicolon) parse failed" +fi + echo "12.7 测试repeat循环" echo 'function test(); begin repeat x := x + 1; until x > 10; end;' | tree-sitter parse > /dev/null 2>&1 if [ $? -eq 0 ]; then