Add tests for more operators.

This commit is contained in:
David Given 2017-01-01 17:44:03 +00:00
parent 374e7a1c57
commit be909fe045

View file

@ -1,12 +1,19 @@
# #
minusone -1;
zero 0; zero 0;
one 1; one 1;
two 2; two 2;
main() main()
{ {
extrn zero, one, two; extrn minusone, zero, one, two;
auto i; auto i, j;
if (!(-one == -1)) fail(__LINE__);
if (!(!one == 0)) fail(__LINE__);
if (!(!zero == 1)) fail(__LINE__);
if (!(~zero == -1)) fail(__LINE__);
if (!(~minusone == 0)) fail(__LINE__);
if (!((two + two) == 4)) fail(__LINE__); if (!((two + two) == 4)) fail(__LINE__);
if (!((two - two) == 0)) fail(__LINE__); if (!((two - two) == 0)) fail(__LINE__);
@ -52,6 +59,25 @@ main()
i = two; i =| 1; if (!(i == 3)) fail(__LINE__); i = two; i =| 1; if (!(i == 3)) fail(__LINE__);
i = two; i =^ 2; if (!(i == 0)) fail(__LINE__); i = two; i =^ 2; if (!(i == 0)) fail(__LINE__);
if (!(one ? 1 : 0)) 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();
} }