Add support for B tests; add a test for the B operators (finding several
compiler bugs in the process).
This commit is contained in:
parent
803b81e3f4
commit
1beedca590
57
tests/plat/b/operators_b.b
Normal file
57
tests/plat/b/operators_b.b
Normal file
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
zero 0;
|
||||
one 1;
|
||||
two 2;
|
||||
|
||||
main()
|
||||
{
|
||||
extrn zero, one, two;
|
||||
auto i;
|
||||
|
||||
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 != one)) fail(__LINE__);
|
||||
if (!(zero < one)) fail(__LINE__);
|
||||
if (!(zero <= one)) fail(__LINE__);
|
||||
if (!(zero <= zero)) fail(__LINE__);
|
||||
if (!(one > zero)) fail(__LINE__);
|
||||
if (!(one >= zero)) fail(__LINE__);
|
||||
if (!(one >= one)) fail(__LINE__);
|
||||
|
||||
if (!((one << 1) == 2)) fail(__LINE__);
|
||||
if (!((two >> 1) == 1)) fail(__LINE__);
|
||||
|
||||
if (!((two & 1) == 0)) fail(__LINE__);
|
||||
if (!((two | 1) == 3)) fail(__LINE__);
|
||||
if (!((two ^ 2) == 0)) fail(__LINE__);
|
||||
|
||||
i = 2; i =+ two; if (!(i == 4)) fail(__LINE__);
|
||||
i = 2; i =- two; if (!(i == 0)) fail(__LINE__);
|
||||
i = 2; i =* two; if (!(i == 4)) fail(__LINE__);
|
||||
i = 2; i =/ two; if (!(i == 1)) fail(__LINE__);
|
||||
i = 2; i =% two; if (!(i == 0)) fail(__LINE__);
|
||||
|
||||
i = zero; i === zero; if (!i) fail(__LINE__);
|
||||
i = zero; i =!= one; if (!i) fail(__LINE__);
|
||||
i = zero; i =< one; if (!i) fail(__LINE__);
|
||||
i = zero; i =<= one; if (!i) fail(__LINE__);
|
||||
i = zero; i =<= zero; if (!i) fail(__LINE__);
|
||||
i = one; i => zero; if (!i) fail(__LINE__);
|
||||
i = one; i =>= zero; if (!i) fail(__LINE__);
|
||||
i = one; i =>= one; if (!i) fail(__LINE__);
|
||||
|
||||
i = one; i =<< one; if (!(i == 2)) fail(__LINE__);
|
||||
i = two; i =>> one; if (!(i == 1)) fail(__LINE__);
|
||||
|
||||
i = two; i =& 1; if (!(i == 0)) fail(__LINE__);
|
||||
i = two; i =| 1; if (!(i == 3)) fail(__LINE__);
|
||||
i = two; i =^ 2; if (!(i == 0)) fail(__LINE__);
|
||||
|
||||
finished();
|
||||
}
|
||||
|
|
@ -12,12 +12,16 @@ definerule("plat_testsuite",
|
|||
"tests/plat/*.c",
|
||||
"tests/plat/*.e",
|
||||
"tests/plat/*.p",
|
||||
"tests/plat/b/*.b",
|
||||
"tests/plat/bugs/*.mod"
|
||||
)
|
||||
|
||||
acklibrary {
|
||||
name = "lib",
|
||||
srcs = { "tests/plat/lib/test.c" },
|
||||
srcs = {
|
||||
"tests/plat/lib/test.c",
|
||||
"tests/plat/lib/test_b.c",
|
||||
},
|
||||
hdrs = {
|
||||
"tests/plat/lib/test.h",
|
||||
"tests/plat/lib/Test.def"
|
||||
|
@ -40,7 +44,7 @@ definerule("plat_testsuite",
|
|||
vars = {
|
||||
plat = e.plat,
|
||||
lang = lang,
|
||||
ackcflags = "-O0"
|
||||
ackcflags = "-O0 -Bmain"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +57,7 @@ definerule("plat_testsuite",
|
|||
"util/build+testrunner"
|
||||
},
|
||||
commands = {
|
||||
"(%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]} || echo FAILED) > %{outs}",
|
||||
"(%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]} || echo @@FAIL) > %{outs}",
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -63,4 +67,4 @@ definerule("plat_testsuite",
|
|||
srcs = tests,
|
||||
}
|
||||
end
|
||||
)
|
||||
)
|
||||
|
|
34
tests/plat/lib/test_b.c
Normal file
34
tests/plat/lib/test_b.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdint.h>
|
||||
#include "test.h"
|
||||
|
||||
extern void patch_addresses(uintptr_t* module);
|
||||
extern uintptr_t* bmodule_main;
|
||||
|
||||
static void i_writehex(intptr_t code)
|
||||
{
|
||||
writehex(code);
|
||||
}
|
||||
|
||||
static void i_fail(intptr_t code)
|
||||
{
|
||||
fail(code);
|
||||
}
|
||||
|
||||
uintptr_t b_finished = (uintptr_t)&finished;
|
||||
uintptr_t b_writehex = (uintptr_t)&i_writehex;
|
||||
uintptr_t b_fail = (uintptr_t)&i_fail;
|
||||
|
||||
static uintptr_t* bmodule_test[] =
|
||||
{
|
||||
&b_finished,
|
||||
&b_writehex,
|
||||
&b_fail,
|
||||
0
|
||||
};
|
||||
|
||||
void binit(void)
|
||||
{
|
||||
patch_addresses(&bmodule_test);
|
||||
patch_addresses(&bmodule_main);
|
||||
}
|
||||
|
Loading…
Reference in a new issue