split tests
This commit is contained in:
parent
2b9ed2e2a4
commit
d0f8b3e0ad
12 changed files with 137 additions and 121 deletions
4
test/basic/comment.c
Normal file
4
test/basic/comment.c
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// hello
|
||||||
|
/* world */
|
||||||
|
|
||||||
|
int main() {}
|
1
test/basic/comment.out
Normal file
1
test/basic/comment.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0
|
39
test/loop/break.c
Normal file
39
test/loop/break.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
int printf(char* format, ...);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// For loop
|
||||||
|
printf("For loop:\n");
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
if (i == 3) {
|
||||||
|
break; // Exit the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// While loop
|
||||||
|
printf("While loop:\n");
|
||||||
|
i = 0;
|
||||||
|
while (i < 5) {
|
||||||
|
if (i == 3) {
|
||||||
|
break; // Exit the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// Do-while loop
|
||||||
|
printf("Do-while loop:\n");
|
||||||
|
i = 0;
|
||||||
|
do {
|
||||||
|
if (i == 3) {
|
||||||
|
break; // Exit the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
i++;
|
||||||
|
} while (i < 5);
|
||||||
|
printf("\n");
|
||||||
|
}
|
7
test/loop/break.out
Normal file
7
test/loop/break.out
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
For loop:
|
||||||
|
0 1 2
|
||||||
|
While loop:
|
||||||
|
0 1 2
|
||||||
|
Do-while loop:
|
||||||
|
0 1 2
|
||||||
|
0
|
41
test/loop/continue.c
Normal file
41
test/loop/continue.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
int printf(char* format, ...);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// For loop
|
||||||
|
printf("For loop:\n");
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
if (i == 3) {
|
||||||
|
continue; // Skip the rest of the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// While loop
|
||||||
|
printf("While loop:\n");
|
||||||
|
i = 0;
|
||||||
|
while (i < 5) {
|
||||||
|
if (i == 3) {
|
||||||
|
i++;
|
||||||
|
continue; // Skip the rest of the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// Do-while loop
|
||||||
|
printf("Do-while loop:\n");
|
||||||
|
i = 0;
|
||||||
|
do {
|
||||||
|
if (i == 3) {
|
||||||
|
i++;
|
||||||
|
continue; // Skip the rest of the loop when i is 3
|
||||||
|
}
|
||||||
|
printf("%d ", i);
|
||||||
|
i++;
|
||||||
|
} while (i < 5);
|
||||||
|
printf("\n");
|
||||||
|
}
|
7
test/loop/continue.out
Normal file
7
test/loop/continue.out
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
For loop:
|
||||||
|
0 1 2 4
|
||||||
|
While loop:
|
||||||
|
0 1 2 4
|
||||||
|
Do-while loop:
|
||||||
|
0 1 2 4
|
||||||
|
0
|
105
test/loop/loop.c
105
test/loop/loop.c
|
@ -1,105 +0,0 @@
|
||||||
int printf(char* format, ...);
|
|
||||||
int scanf(char* format, ...);
|
|
||||||
|
|
||||||
/* **dummy** loop test generated by copilot */
|
|
||||||
|
|
||||||
void test_continue() {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// For loop
|
|
||||||
printf("For loop:\n");
|
|
||||||
for (i = 0; i < 5; i++) {
|
|
||||||
if (i == 3) {
|
|
||||||
continue; // Skip the rest of the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// While loop
|
|
||||||
printf("While loop:\n");
|
|
||||||
i = 0;
|
|
||||||
while (i < 5) {
|
|
||||||
if (i == 3) {
|
|
||||||
i++;
|
|
||||||
continue; // Skip the rest of the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// Do-while loop
|
|
||||||
printf("Do-while loop:\n");
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
if (i == 3) {
|
|
||||||
i++;
|
|
||||||
continue; // Skip the rest of the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
i++;
|
|
||||||
} while (i < 5);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_break() {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// For loop
|
|
||||||
printf("For loop:\n");
|
|
||||||
for (i = 0; i < 5; i++) {
|
|
||||||
if (i == 3) {
|
|
||||||
break; // Exit the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// While loop
|
|
||||||
printf("While loop:\n");
|
|
||||||
i = 0;
|
|
||||||
while (i < 5) {
|
|
||||||
if (i == 3) {
|
|
||||||
break; // Exit the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// Do-while loop
|
|
||||||
printf("Do-while loop:\n");
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
if (i == 3) {
|
|
||||||
break; // Exit the loop when i is 3
|
|
||||||
}
|
|
||||||
printf("%d ", i);
|
|
||||||
i++;
|
|
||||||
} while (i < 5);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_nested() {
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
// For loop
|
|
||||||
printf("For loop:\n");
|
|
||||||
for (i = 0; i < 5; i++) {
|
|
||||||
for (j = 0; j < 5; j++) {
|
|
||||||
if (i >= 2 && j >= 2 && i + j >= 5) {
|
|
||||||
return; // Exit nested loop via return
|
|
||||||
}
|
|
||||||
printf("(%d, %d) ", i, j);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
test_continue();
|
|
||||||
test_break();
|
|
||||||
test_nested();
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
For loop:
|
|
||||||
0 1 2 4
|
|
||||||
While loop:
|
|
||||||
0 1 2 4
|
|
||||||
Do-while loop:
|
|
||||||
0 1 2 4
|
|
||||||
For loop:
|
|
||||||
0 1 2
|
|
||||||
While loop:
|
|
||||||
0 1 2
|
|
||||||
Do-while loop:
|
|
||||||
0 1 2
|
|
||||||
For loop:
|
|
||||||
(0, 0) (0, 1) (0, 2) (0, 3) (0, 4)
|
|
||||||
(1, 0) (1, 1) (1, 2) (1, 3) (1, 4)
|
|
||||||
(2, 0) (2, 1) (2, 2) 0
|
|
20
test/loop/nested.c
Normal file
20
test/loop/nested.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
int printf(char* format, ...);
|
||||||
|
|
||||||
|
void test() {
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
if (i >= 2 && j >= 2 && i + j >= 5) {
|
||||||
|
return; // Exit nested loop via return
|
||||||
|
}
|
||||||
|
printf("(%d, %d)%c", i, j, " \n"[j == 4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
test();
|
||||||
|
printf("\n");
|
||||||
|
}
|
4
test/loop/nested.out
Normal file
4
test/loop/nested.out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(0, 0) (0, 1) (0, 2) (0, 3) (0, 4)
|
||||||
|
(1, 0) (1, 1) (1, 2) (1, 3) (1, 4)
|
||||||
|
(2, 0) (2, 1) (2, 2)
|
||||||
|
0
|
9
test/operator/unary.c
Normal file
9
test/operator/unary.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
int printf(char* format, ...);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a = 5;
|
||||||
|
printf("+a=%d\n", +a);
|
||||||
|
printf("-a=%d\n", -a);
|
||||||
|
printf("!a=%d\n", !a);
|
||||||
|
printf("~a=%d\n", ~a);
|
||||||
|
}
|
5
test/operator/unary.out
Normal file
5
test/operator/unary.out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
+a=5
|
||||||
|
-a=-5
|
||||||
|
!a=0
|
||||||
|
~a=-6
|
||||||
|
0
|
Loading…
Add table
Add a link
Reference in a new issue