test: golden testler — operatör önceliği, döngüler, folding, DCE

closes #99, #100, #104, #105

- arithmetic/precedence: Pratt öncelik + sol-birliktelik + modulo
- loops/basic: while/do-while/for üçü de 0,1,2 üretiyor
- loops/do_while_once: koşul baştan yanlış, gövde yine de bir kez çalışıyor
- opt/folding: sabit katlama çıktısı (14,3,1,0,1,0,0)
- opt/dce: ölü return sonrası kod programı etkilemiyor (10,0,0)
9/9 ctest geçti
This commit is contained in:
saqut 2026-06-18 22:33:19 +03:00
parent 27a5bc753e
commit c67246c99a
10 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,6 @@
7
9
3
3
1
11

View File

@ -0,0 +1,9 @@
int main() {
print(1 + 2 * 3);
print((1 + 2) * 3);
print(10 - 4 - 3);
print(10 / 3);
print(10 % 3);
print(2 + 3 * 4 - 6 / 2);
return 0;
}

View File

@ -0,0 +1,9 @@
0
1
2
0
1
2
0
1
2

View File

@ -0,0 +1,18 @@
int main() {
int i = 0;
while (i < 3) {
print(i);
i = i + 1;
}
int j = 0;
do {
print(j);
j = j + 1;
} while (j < 3);
for (int k = 0; k < 3; k = k + 1) {
print(k);
}
return 0;
}

View File

@ -0,0 +1 @@
5

View File

@ -0,0 +1,8 @@
int main() {
int x = 5;
do {
print(x);
x = x + 1;
} while (x < 0);
return 0;
}

View File

@ -0,0 +1,3 @@
10
0
0

14
tests/golden/opt/dce.sqt Normal file
View File

@ -0,0 +1,14 @@
int hesapla(int n) {
if (n > 0) {
return n * 2;
print(99);
}
return 0;
}
int main() {
print(hesapla(5));
print(hesapla(0));
print(hesapla(-3));
return 0;
}

View File

@ -0,0 +1,7 @@
14
3
1
0
1
0
0

View File

@ -0,0 +1,10 @@
int main() {
print(2 + 3 * 4);
print((10 - 4) / 2);
print(1 == 1);
print(0 == 1);
print(1 + 2 == 3);
print(0 && 1);
print(1 || 0);
return 0;
}