From 36f76b2a4a050ba9d7e64d11a87366ba9a7cf284 Mon Sep 17 00:00:00 2001 From: origami-b <972397381@qq.com> Date: Fri, 15 Dec 2023 19:54:57 +0800 Subject: [PATCH] add test case --- Student/task3/test/21_float_defn.out | 1 + Student/task3/test/21_float_defn.sy | 8 +++++++ Student/task3/test/22_float_array.out | 1 + Student/task3/test/22_float_array.sy | 5 +++++ Student/task3/test/23_const_defn_infunc.out | 1 + Student/task3/test/23_const_defn_infunc.sy | 6 +++++ .../task3/test/24_const_float_array_defn.out | 1 + .../task3/test/24_const_float_array_defn.sy | 7 ++++++ Student/task3/test/25_float_func.out | 1 + Student/task3/test/25_float_func.sy | 13 +++++++++++ Student/task3/test/26_if_nest.out | 1 + Student/task3/test/26_if_nest.sy | 15 +++++++++++++ Student/task3/test/27_while_nest.out | 1 + Student/task3/test/27_while_nest.sy | 21 ++++++++++++++++++ Student/task3/test/28_cond.in | 1 + Student/task3/test/28_cond.out | 1 + Student/task3/test/28_cond.sy | 22 +++++++++++++++++++ 17 files changed, 106 insertions(+) create mode 100644 Student/task3/test/21_float_defn.out create mode 100644 Student/task3/test/21_float_defn.sy create mode 100644 Student/task3/test/22_float_array.out create mode 100644 Student/task3/test/22_float_array.sy create mode 100644 Student/task3/test/23_const_defn_infunc.out create mode 100644 Student/task3/test/23_const_defn_infunc.sy create mode 100644 Student/task3/test/24_const_float_array_defn.out create mode 100644 Student/task3/test/24_const_float_array_defn.sy create mode 100644 Student/task3/test/25_float_func.out create mode 100644 Student/task3/test/25_float_func.sy create mode 100644 Student/task3/test/26_if_nest.out create mode 100644 Student/task3/test/26_if_nest.sy create mode 100644 Student/task3/test/27_while_nest.out create mode 100644 Student/task3/test/27_while_nest.sy create mode 100644 Student/task3/test/28_cond.in create mode 100644 Student/task3/test/28_cond.out create mode 100644 Student/task3/test/28_cond.sy diff --git a/Student/task3/test/21_float_defn.out b/Student/task3/test/21_float_defn.out new file mode 100644 index 0000000..d99e90e --- /dev/null +++ b/Student/task3/test/21_float_defn.out @@ -0,0 +1 @@ +29 \ No newline at end of file diff --git a/Student/task3/test/21_float_defn.sy b/Student/task3/test/21_float_defn.sy new file mode 100644 index 0000000..5fd78d0 --- /dev/null +++ b/Student/task3/test/21_float_defn.sy @@ -0,0 +1,8 @@ +float a,b; + +int main(){ + a=10.2; + b=5.3; + float c=a*2+b*1.1+3.6; + return c; +} \ No newline at end of file diff --git a/Student/task3/test/22_float_array.out b/Student/task3/test/22_float_array.out new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/Student/task3/test/22_float_array.out @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/Student/task3/test/22_float_array.sy b/Student/task3/test/22_float_array.sy new file mode 100644 index 0000000..81defce --- /dev/null +++ b/Student/task3/test/22_float_array.sy @@ -0,0 +1,5 @@ +float a[2] = {1.2, 1.3}; +int main(){ + a[1] = 3.3; + return 0; +} diff --git a/Student/task3/test/23_const_defn_infunc.out b/Student/task3/test/23_const_defn_infunc.out new file mode 100644 index 0000000..bf0d87a --- /dev/null +++ b/Student/task3/test/23_const_defn_infunc.out @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git a/Student/task3/test/23_const_defn_infunc.sy b/Student/task3/test/23_const_defn_infunc.sy new file mode 100644 index 0000000..a6c7cc9 --- /dev/null +++ b/Student/task3/test/23_const_defn_infunc.sy @@ -0,0 +1,6 @@ +const int x=4; + +int main(){ + const int x=4; + return x; +} \ No newline at end of file diff --git a/Student/task3/test/24_const_float_array_defn.out b/Student/task3/test/24_const_float_array_defn.out new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/Student/task3/test/24_const_float_array_defn.out @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/Student/task3/test/24_const_float_array_defn.sy b/Student/task3/test/24_const_float_array_defn.sy new file mode 100644 index 0000000..87b2b05 --- /dev/null +++ b/Student/task3/test/24_const_float_array_defn.sy @@ -0,0 +1,7 @@ +const float a[5]={0.2,1.33,2.4,3.5,4.6}; +const int b = 3; +float c = a[b + 1]; + +int main(){ + return a[4] + c; +} \ No newline at end of file diff --git a/Student/task3/test/25_float_func.out b/Student/task3/test/25_float_func.out new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/Student/task3/test/25_float_func.out @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/Student/task3/test/25_float_func.sy b/Student/task3/test/25_float_func.sy new file mode 100644 index 0000000..1217761 --- /dev/null +++ b/Student/task3/test/25_float_func.sy @@ -0,0 +1,13 @@ +float a,b,c; + +void add(float a,float b){ + c=a+b; + return; +} + +int main(){ + a=3.3; + b=2.8; + add(a,b); + return c; +} \ No newline at end of file diff --git a/Student/task3/test/26_if_nest.out b/Student/task3/test/26_if_nest.out new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/Student/task3/test/26_if_nest.out @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/Student/task3/test/26_if_nest.sy b/Student/task3/test/26_if_nest.sy new file mode 100644 index 0000000..89f8b93 --- /dev/null +++ b/Student/task3/test/26_if_nest.sy @@ -0,0 +1,15 @@ +int a; +int main(){ + a = -10; + if( a>0 ){ + return 1; + } + else{ + if(a > -5) { + return 2; + } + else { + return 0; + } + } +} diff --git a/Student/task3/test/27_while_nest.out b/Student/task3/test/27_while_nest.out new file mode 100644 index 0000000..2b82dfe --- /dev/null +++ b/Student/task3/test/27_while_nest.out @@ -0,0 +1 @@ +60 \ No newline at end of file diff --git a/Student/task3/test/27_while_nest.sy b/Student/task3/test/27_while_nest.sy new file mode 100644 index 0000000..c433ba0 --- /dev/null +++ b/Student/task3/test/27_while_nest.sy @@ -0,0 +1,21 @@ +int a; +int b; +int main(){ + b=0; + a=3; + int sum = 0; + while(b<10){ + b = b+1; + while(a > 0) { + a = a-1; + sum = sum + b; + } + sum = sum + b; + } + + while(b < 12) { + sum = sum + 1; + b = b+1; + } + return sum; +} diff --git a/Student/task3/test/28_cond.in b/Student/task3/test/28_cond.in new file mode 100644 index 0000000..316bd14 --- /dev/null +++ b/Student/task3/test/28_cond.in @@ -0,0 +1 @@ +3 2 \ No newline at end of file diff --git a/Student/task3/test/28_cond.out b/Student/task3/test/28_cond.out new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/Student/task3/test/28_cond.out @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/Student/task3/test/28_cond.sy b/Student/task3/test/28_cond.sy new file mode 100644 index 0000000..e3560f1 --- /dev/null +++ b/Student/task3/test/28_cond.sy @@ -0,0 +1,22 @@ +int a; +int b; +int main(){ + a = getint(); + b = getint(); + if ( a == b ){ + return 1; + } + if ( a <= b ){ + return 2; + } + if ( a < b ){ + return 3; + } + if ( a != b){ + return 4; + } + if ( a >= b){ + return 5; + } + return 0; +}