fix(run_ir_test): 之前的脚本不适配测试用例

pull/3/head
Junhe Wu 5 days ago
parent db75940592
commit da4e8fd860

@ -28,21 +28,12 @@ while IFS= read -r test_file; do
echo -n "测试: $relative_path ... "
# stderr 单独捕获stdout 写到输出文件
err_output=$("$COMPILER" --emit-ir "$test_file" > "$output_file" 2>&1)
"$COMPILER" --emit-ir "$test_file" > "$output_file" 2>&1
exit_code=$?
if [ $exit_code -eq 0 ]; then
# 确认输出文件非空且不含 [error]
if [ -s "$output_file" ] && ! grep -q '\[error\]' "$output_file"; then
echo "通过"
pass_count=$((pass_count + 1))
else
echo "失败 (生成内容含错误)"
fail_count=$((fail_count + 1))
failed_cases+=("$relative_path")
echo " 错误信息已保存到: $output_file"
fi
if [ $exit_code -eq 0 ] && [ -s "$output_file" ] && ! grep -q '\[error\]' "$output_file"; then
echo "通过"
pass_count=$((pass_count + 1))
else
echo "失败"
fail_count=$((fail_count + 1))

@ -1,9 +0,0 @@
const float PI = 3.14;
const float E = 2.718;
int main() {
float r = 5.0;
float area = PI * r * r;
float sum = PI + E;
return 0;
}

@ -1,8 +0,0 @@
int main() {
float a = 3.14;
float b = 2.0;
float c = a + b;
int d = 10;
float e = d + a; // 隐式转换 int -> float
return 0;
}

@ -1,30 +0,0 @@
float test_float(float x, int y) {
float z = x * 2.5;
float w = y + z; // 隐式转换 int -> float
return w / 3.0;
}
int main() {
float a = 1.5;
float b = 2.5;
// 浮点运算
float c = a + b;
float d = a - b;
float e = a * b;
float f = a / b;
// 浮点比较
int g = a < b;
int h = a == b;
// 一元运算
float i = -a;
int j = !a;
// 混合运算(隐式转换)
int k = 10;
float m = k + a;
return 0;
}

@ -1,18 +0,0 @@
float test_float(float x, int y) {
float z = x * 2.5;
float w = y + z;
return w / 3.0;
}
int main() {
float a = 1.5;
float b = 2.5;
float c = a + b;
float d = a - b;
float e = a * b;
float f = a / b;
float g = -a;
int k = 10;
float m = k + a;
return 0;
}
Loading…
Cancel
Save