Skip to content

Commit

Permalink
[lab3] fix bugs and release test
Browse files Browse the repository at this point in the history
  • Loading branch information
chiakicage committed May 10, 2024
1 parent ed300d2 commit eb91959
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ir/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl fmt::Display for BinaryOp {
BinaryOp::Mul => write!(f, "mul"),
BinaryOp::Div => write!(f, "div"),
BinaryOp::Rem => write!(f, "rem"),
BinaryOp::And => write!(f, "or"),
BinaryOp::Or => write!(f, "and"),
BinaryOp::And => write!(f, "and"),
BinaryOp::Or => write!(f, "or"),
BinaryOp::Xor => write!(f, "xor"),
BinaryOp::Lt => write!(f, "lt"),
BinaryOp::Gt => write!(f, "gt"),
Expand Down
1 change: 1 addition & 0 deletions tests/lab3/array_parameter.sy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ void print_array(int a[], int len) {
int i = 0;
while (i < len) {
putint(a[i]);
putch(32);
i = i + 1;
}
return;
Expand Down
1 change: 1 addition & 0 deletions tests/lab3/combinator.sy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ int main() {
int n = getint();
int k = getint();
putint(cal_combiniation(n, k));
putch(32);
putint(cal_permutation(n, k));
return 0;
}
2 changes: 0 additions & 2 deletions tests/lab3/global_test1.sy
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ int c[4][3];
int i = 2024;

int main() {
a = 0;

while (a < 2) {
b[a] = a * 2;
a = a + 1;
Expand Down
1 change: 1 addition & 0 deletions tests/lab3/merge_sort.sy
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int main() {
i = 0;
while (i < n) {
putint(arr[i]);
putch(32);
i = i + 1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions tests/lab3/quick_sort.sy
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int main() {
i = 0;
while (i < n) {
putint(arr[i]);
putch(32);
i = i + 1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions tests/lab3/sort_array.sy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ int main() {
i = 0;
while (i < 5) {
putint(a[i]);
putch(32);
i = i + 1;
}
return 0;
Expand Down
5 changes: 5 additions & 0 deletions tests/lab3/sudoku.sy
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ int main() {
a[i][j] = getint();
if (a[i][j] < 0 || a[i][j] > 9) {
putint(0);
putch(32);
return 0;
} else if (a[i][j] == 0) {
solve = 1;
Expand All @@ -145,17 +146,21 @@ int main() {
j = 0;
while (j < 9) {
putint(a[i][j]);
putch(32);
j = j + 1;
}
i = i + 1;
}
} else {
putint(0);
putch(32);
}
} else if (check_sudoku(a)) {
putint(1);
putch(32);
} else {
putint(0);
putch(32);
}

return 0;
Expand Down
3 changes: 3 additions & 0 deletions tests/lab3/two_dimension_array.sy
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ int main() {
}

putint(mat[0][3]);
putch(32);
putint(mat[1][2]);
putch(32);
putint(mat[2][1]);
putch(32);
putint(mat[3][0]);

return 0;
Expand Down
1 change: 0 additions & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def __init__(self, test: Test, output: str | None | list[str], exit_code: int, c
self.passed = exit_code == 0
else:
if not concat_output: # lab3
print(output, test.expected)
self.passed = exit_code == 0 and output == test.expected
else: # lab4
expected = "".join(test.expected)
Expand Down

0 comments on commit eb91959

Please sign in to comment.