diff --git a/test/test_case/case_lab3_1/array_1d.out b/test/test_case/case_lab3_1/array_1d.out new file mode 100644 index 0000000..3674aab --- /dev/null +++ b/test/test_case/case_lab3_1/array_1d.out @@ -0,0 +1,2 @@ +0 1 4 9 16 +0 diff --git a/test/test_case/case_lab3_1/array_1d.sy b/test/test_case/case_lab3_1/array_1d.sy new file mode 100644 index 0000000..2850075 --- /dev/null +++ b/test/test_case/case_lab3_1/array_1d.sy @@ -0,0 +1,16 @@ +int a[5]; +int main() { + int i = 0; + while (i < 5) { + a[i] = i * i; + i = i + 1; + } + i = 0; + while (i < 5) { + putint(a[i]); + putch(32); + i = i + 1; + } + putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/div_mod.out b/test/test_case/case_lab3_1/div_mod.out new file mode 100644 index 0000000..27da0f8 --- /dev/null +++ b/test/test_case/case_lab3_1/div_mod.out @@ -0,0 +1,2 @@ +13 7 30 3 1 +0 diff --git a/test/test_case/case_lab3_1/div_mod.sy b/test/test_case/case_lab3_1/div_mod.sy new file mode 100644 index 0000000..4f964e0 --- /dev/null +++ b/test/test_case/case_lab3_1/div_mod.sy @@ -0,0 +1,10 @@ +int main() { + int a = 10; + int b = 3; + putint(a + b); putch(32); + putint(a - b); putch(32); + putint(a * b); putch(32); + putint(a / b); putch(32); + putint(a % b); putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/float_calc.out b/test/test_case/case_lab3_1/float_calc.out new file mode 100644 index 0000000..55d583a --- /dev/null +++ b/test/test_case/case_lab3_1/float_calc.out @@ -0,0 +1,2 @@ +0x1.cp+1 -0x1p-1 0x1.8p+1 0x1.8p-1 +0 diff --git a/test/test_case/case_lab3_1/float_calc.sy b/test/test_case/case_lab3_1/float_calc.sy new file mode 100644 index 0000000..98a61ab --- /dev/null +++ b/test/test_case/case_lab3_1/float_calc.sy @@ -0,0 +1,9 @@ +int main() { + float a = 1.5; + float b = 2.0; + putfloat(a + b); putch(32); + putfloat(a - b); putch(32); + putfloat(a * b); putch(32); + putfloat(a / b); putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/if_else_nested.out b/test/test_case/case_lab3_1/if_else_nested.out new file mode 100644 index 0000000..043e571 --- /dev/null +++ b/test/test_case/case_lab3_1/if_else_nested.out @@ -0,0 +1,2 @@ +3 +0 diff --git a/test/test_case/case_lab3_1/if_else_nested.sy b/test/test_case/case_lab3_1/if_else_nested.sy new file mode 100644 index 0000000..dc7e23e --- /dev/null +++ b/test/test_case/case_lab3_1/if_else_nested.sy @@ -0,0 +1,19 @@ +int main() { + int a = 5; + int b = 10; + if (a > b) { + putint(1); + } else { + if (a == 5) { + if (b != 10) { + putint(2); + } else { + putint(3); + } + } else { + putint(4); + } + } + putch(10); + return 0; +} diff --git a/test/test_case/case_lab3_1/recursion.out b/test/test_case/case_lab3_1/recursion.out new file mode 100644 index 0000000..9807191 --- /dev/null +++ b/test/test_case/case_lab3_1/recursion.out @@ -0,0 +1,2 @@ +8 +0 diff --git a/test/test_case/case_lab3_1/recursion.sy b/test/test_case/case_lab3_1/recursion.sy new file mode 100644 index 0000000..67a71b8 --- /dev/null +++ b/test/test_case/case_lab3_1/recursion.sy @@ -0,0 +1,10 @@ +int fib(int n) { + if (n <= 1) return n; + return fib(n-1) + fib(n-2); +} +int main() { + int n = 6; + putint(fib(n)); + putch(10); + return 0; +}