mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Add a test for while (count--)
This commit is contained in:
parent
49ca09a64f
commit
95bd4ad410
1 changed files with 29 additions and 0 deletions
29
tools/qfcc/test/while.r
Normal file
29
tools/qfcc/test/while.r
Normal file
|
@ -0,0 +1,29 @@
|
|||
int min;
|
||||
int times;
|
||||
|
||||
void bar (int x)
|
||||
{
|
||||
if (x < min)
|
||||
min = x;
|
||||
}
|
||||
|
||||
void foo (int count)
|
||||
{
|
||||
int safety = count; // in case qfcc screws up (prevents infinite loop)
|
||||
min = count;
|
||||
while (count--) { //XXX this is the code being tested
|
||||
bar (count);
|
||||
times++;
|
||||
safety--;
|
||||
if (safety < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int c = 3;
|
||||
foo (c);
|
||||
return min || times != c;
|
||||
}
|
Loading…
Reference in a new issue