bloat-buster/tests/break_continue.nat
2024-07-23 21:29:38 +02:00

167 lines
1.9 KiB
Plaintext

fn fn0(arg: s32) s32
{
>a = arg;
while (a < 10)
{
a = a + 1;
if (a == 5)
{
break;
}
if (a == 6)
{
break;
}
}
return a;
}
fn fn1(arg: s32) s32
{
>a: s32 = 1;
>i = arg;
while (i < 10)
{
i = i + 1;
if (i == 5)
{
continue;
}
if (i == 7)
{
continue;
}
a = a + 1;
}
return a;
}
fn fn2(arg: s32) s32
{
>i = arg;
while (i < 10)
{
i = i + 1;
if (i == 5)
{
continue;
}
if (i == 6)
{
break;
}
}
return i;
}
fn fn3(arg: s32) s32
{
>i = arg;
while (i < 10)
{
i = i + 1;
if (i == 6)
{
break;
}
}
return i;
}
fn fn4(arg: s32) s32
{
>i = arg;
while (i < 10)
{
i = i + 1;
if (i == 5)
{
continue;
}
if (i == 6)
{
continue;
}
}
return i;
}
fn fn5(arg: s32) s32
{
>i = arg;
while (i < 10)
{
i = i + 1;
if (i == 5)
{
continue;
}
}
return i;
}
fn fn6(arg: s32) s32
{
>i = arg;
while (i < 10)
{
>a = i + 2;
if (a > 4)
{
break;
}
}
return i;
}
fn fn7(arg: s32) s32
{
>i = arg;
while (i < 10)
{
break;
}
return i;
}
fn fn8(arg: s32) s32
{
>a: s32 = 1;
while (1)
{
a = a + 1;
if (a < 10)
{
continue;
}
break;
}
return a;
}
fn[cc(.c)] main[export]() s32
{
return fn0(0) +
fn1(1) +
fn2(2) +
fn3(3) +
fn4(4) +
fn5(5) +
fn6(6) +
fn7(7) +
fn8(8);
}