Make sure that constant folding doesn't render our tests trivial.

This commit is contained in:
David Given 2017-01-07 19:53:57 +01:00
parent abbead482a
commit 837b9622fb

View file

@ -1,65 +1,70 @@
#
/* External variables to defeat constant folding. */
zero 0;
one 1;
i 0;
ext_t()
{
extrn i;
extrn zero, one, i;
i = 0;
i = zero;
if (!(i++ == 0)) fail(__LINE__);
i == 1;
i = one;
if (!(i-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
i = zero;
if (!(++i == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
i = one;
if (!(--i == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}
int_t()
{
auto i;
extrn zero, one;
auto i;
i = 0;
i = zero;
if (!(i++ == 0)) fail(__LINE__);
i == 1;
i = one;
if (!(i-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
i = zero;
if (!(++i == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
i = one;
if (!(--i == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}
star_t()
{
extrn i;
extrn zero, one, i;
auto p;
p = &i;
i = 0;
i = zero;
if (!((*p)++ == 0)) fail(__LINE__);
i == 1;
i = one;
if (!((*p)-- == 1)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
i = 0;
i = zero;
if (!(++(*p) == 1)) fail(__LINE__);
if (!(i == 1)) fail(__LINE__);
i == 1;
i = one;
if (!(--(*p) == 0)) fail(__LINE__);
if (!(i == 0)) fail(__LINE__);
}