1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-18 00:07:21 +00:00
cc65/test/val/while.c

108 lines
1.2 KiB
C
Raw Normal View History

2014-09-24 14:45:10 +00:00
/*
!!DESCRIPTION!! while-condition tests
2014-09-24 14:45:10 +00:00
!!ORIGIN!! SDCC regression tests
!!LICENCE!! GPL, read COPYING.GPL
*/
#include <stdio.h>
static unsigned char failures = 0x00;
static unsigned char achar0 = 0;
static void
while1 (void)
2014-09-24 14:45:10 +00:00
{
unsigned char i = 10;
do {
++achar0;
} while (--i);
if (achar0 != 10) {
failures |= 0x01;
}
2014-09-24 14:45:10 +00:00
}
static void
while2 (void)
2014-09-24 14:45:10 +00:00
{
unsigned char i = 10;
achar0 = 0;
while (--i) {
++achar0;
}
if (achar0 != 10 - 1) {
failures |= 0x02;
}
}
static void
while3 (void)
{
achar0 = 0;
do {
if (++achar0 == (unsigned char)0) {
return;
2014-09-24 14:45:10 +00:00
}
} while (1);
2014-09-24 14:45:10 +00:00
failures |= 0x04;
}
static void
while4 (void)
{
achar0 = 0;
while (1) {
if (++achar0 == (unsigned char)0) {
return;
}
}
failures |= 0x08;
}
static void
while5 (void)
{
achar0 = 0;
do {
++achar0;
} while (0);
if (achar0 != 1) {
failures |= 0x10;
}
}
static void
while6 (void)
{
achar0 = 0;
while (0) {
++achar0;
}
if (achar0 != 1 - 1) {
failures |= 0x20;
}
2014-09-24 14:45:10 +00:00
}
int
main (void)
{
while1 ();
while2 ();
while3 ();
while4 ();
while5 ();
while6 ();
2014-09-24 14:45:10 +00:00
if (failures) {
printf("failures: 0x%02X\n", failures);
}
2014-09-24 14:45:10 +00:00
return failures;
}