From be909fe0450a3165d3458feed7dd5679546ded35 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 1 Jan 2017 17:44:03 +0000 Subject: [PATCH] Add tests for more operators. --- tests/plat/b/operators_b.b | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/plat/b/operators_b.b b/tests/plat/b/operators_b.b index 5a4c1d91f..796b82906 100644 --- a/tests/plat/b/operators_b.b +++ b/tests/plat/b/operators_b.b @@ -1,12 +1,19 @@ # +minusone -1; zero 0; one 1; two 2; main() { - extrn zero, one, two; - auto i; + extrn minusone, zero, one, two; + 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) == 0)) fail(__LINE__); @@ -52,6 +59,25 @@ main() i = two; i =| 1; if (!(i == 3)) 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(); }