Moved the inc/dec operator tests into their own source file; more exhaustive

testing.
This commit is contained in:
David Given 2017-01-07 18:38:43 +01:00
parent 6b4f8d72b8
commit 39215c131e
2 changed files with 85 additions and 23 deletions

77
tests/plat/b/incdec_b.b Normal file
View file

@ -0,0 +1,77 @@
#
i 0;
ext_t()
{
extrn i;
i = 0;
if (!(i++ == 0)) fail(__LINE__);
i == 1;
if (!(i-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
if (!(++i == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
if (!(--i == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}
int_t()
{
auto i;
i = 0;
if (!(i++ == 0)) fail(__LINE__);
i == 1;
if (!(i-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
if (!(++i == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
if (!(--i == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}
star_t()
{
extrn i;
auto p;
p = &i;
i = 0;
if (!((*p)++ == 0)) fail(__LINE__);
i == 1;
if (!((*p)-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
if (!(++(*p) == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
if (!(--(*p) == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}
main()
{
ext_t();
int_t();
star_t();
finished();
return(0);
}

View file

@ -9,18 +9,14 @@ main()
extrn minusone, zero, one, two; extrn minusone, zero, one, two;
auto i, j; auto i, j;
if (!(zero == 0)) fail(__LINE__);
if (!(one == 1)) fail(__LINE__);
if (!(-one == -1)) fail(__LINE__); if (!(-one == -1)) fail(__LINE__);
if (!(!one == 0)) fail(__LINE__); if (!(!one == 0)) fail(__LINE__);
if (!(!zero == 1)) fail(__LINE__); if (!(!zero == 1)) fail(__LINE__);
if (!(~zero == -1)) fail(__LINE__); if (!(~zero == -1)) fail(__LINE__);
if (!(~minusone == 0)) fail(__LINE__); if (!(~minusone == 0)) fail(__LINE__);
if (!((two + two) == 4)) fail(__LINE__);
if (!((two - two) == 0)) fail(__LINE__);
if (!((two * two) == 4)) fail(__LINE__);
if (!((two / two) == 1)) fail(__LINE__);
if (!((two % two) == 0)) fail(__LINE__);
if (!(zero == zero)) fail(__LINE__); if (!(zero == zero)) fail(__LINE__);
if (!(zero != one)) fail(__LINE__); if (!(zero != one)) fail(__LINE__);
if (!(zero < one)) fail(__LINE__); if (!(zero < one)) fail(__LINE__);
@ -30,6 +26,12 @@ main()
if (!(one >= zero)) fail(__LINE__); if (!(one >= zero)) fail(__LINE__);
if (!(one >= one)) fail(__LINE__); if (!(one >= one)) fail(__LINE__);
if (!((two + two) == 4)) fail(__LINE__);
if (!((two - two) == 0)) fail(__LINE__);
if (!((two * two) == 4)) fail(__LINE__);
if (!((two / two) == 1)) fail(__LINE__);
if (!((two % two) == 0)) fail(__LINE__);
if (!((one << 1) == 2)) fail(__LINE__); if (!((one << 1) == 2)) fail(__LINE__);
if (!((two >> 1) == 1)) fail(__LINE__); if (!((two >> 1) == 1)) fail(__LINE__);
@ -62,23 +64,6 @@ main()
if (!(one ? 1 : 0)) fail(__LINE__); if (!(one ? 1 : 0)) fail(__LINE__);
if (!(zero ? 0 : 1)) fail(__LINE__); if (!(zero ? 0 : 1)) fail(__LINE__);
i = 0;
if (!(i++ == 0)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
if (!(i-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
if (!(++i == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
if (!(--i == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
finished(); finished();
return(0); return(0);
} }