Skip to content

Commit

Permalink
add tests for nested loops
Browse files Browse the repository at this point in the history
  • Loading branch information
IngeniariusSoftware committed Jun 12, 2022
1 parent 09728fb commit 4b33641
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
13 changes: 0 additions & 13 deletions project/tests/in_progress/for_main/break_continue/continue01.c

This file was deleted.

19 changes: 19 additions & 0 deletions project/tests/main/for/nested_for01/nested_for01.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//clang -Xclang -ast-dump -fsyntax-only test07.c

#include "stdio.h"

int main() {
for (long long i=0; i<3; i++)
{
printf("%d\n",i);
for (long long j=0; j<3; j++)
{
printf("%d\n",j);
for (long long k=0; k<3; k++)
{
printf("%d\n",k);
}
}
}
return 0;
}
25 changes: 25 additions & 0 deletions project/tests/main/while/nested_dowhile01/nested_dowhile01.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//clang -Xclang -ast-dump -fsyntax-only test07.c

#include "stdio.h"

int main() {
long long i = 0;
do
{
i++;
printf("%d\n", i);
long long j = 0;
do
{
j++;
printf("%d\n", j);
long long k = 0;
do
{
k++;
printf("%d\n", k);
} while (k < 3);
} while (j < 3);
} while (i < 3);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,22 @@

int main() {
long long i = 0;
while (i < 3) {
while (i < 3)
{
i++;
if (i % 2 == 0) {
continue;
}
printf("%d\n", i);
long long j = 0;
while (j < 3) {
while (j < 3)
{
j++;
if (j % 2 == 0) {
continue;
}
printf("%d\n", j);
long long k = 0;
while (k < 3) {
while (k < 3)
{
k++;
if (k % 2 == 0) {
continue;
}
printf("%d\n", k);
}
}
}
return 0;
}
}

0 comments on commit 4b33641

Please sign in to comment.