diff --git a/tests/59_break_before_loop.c b/tests/59_break_before_loop.c new file mode 100644 index 0000000..43780c5 --- /dev/null +++ b/tests/59_break_before_loop.c @@ -0,0 +1,47 @@ +#include + +void foo() +{ + printf("foo\n"); +} +int main() +{ + int a,c; + + printf("\nTest 1\n"); + + a = 0; c = 0; + while (1) + { + printf("a=%d\n", a++); + break; + for (c=0;c<10;c++) + printf("c=%d\n",c); + } + + printf("\nTest 2\n"); + + a = 0; c = 0; + while (1) + { + printf("a=%d\n", a++); + break; + while (c < 3) + printf("c=%d\n",c++); + } + + printf("\nTest 3\n"); + + a = 0; c = 0; + for (c=0;c<10;c++) + { + printf("c=%d\n",c); + foo(); + break; + foo(); + for (a = 0; a < 2; a++) + printf("a=%d\n",a); + } + + return 0; +} diff --git a/tests/59_break_before_loop.expect b/tests/59_break_before_loop.expect new file mode 100644 index 0000000..362e48b --- /dev/null +++ b/tests/59_break_before_loop.expect @@ -0,0 +1,10 @@ + +Test 1 +a=0 + +Test 2 +a=0 + +Test 3 +c=0 +foo diff --git a/tests/Makefile b/tests/Makefile index a160023..a67b318 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -50,7 +50,8 @@ TESTS= 00_assignment.test \ 52_unnamed_enum.test \ 54_goto.test \ 55_array_initialiser.test \ - 56_cross_structure.test + 56_cross_structure.test \ + 59_break_before_loop.test %.test: %.expect %.c @echo Test: $*...