From ae9e103995c1d809be7b8717905593e7dbbf9d17 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 13 Jul 2024 20:56:26 +0300 Subject: bytecode tests pass --- tests/negr_f.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'tests/negr_f.c') diff --git a/tests/negr_f.c b/tests/negr_f.c index 08b6364..d6fee7b 100644 --- a/tests/negr_f.c +++ b/tests/negr_f.c @@ -1,26 +1,23 @@ -#include "test.h" +#include +#include +#include "do_jit.h" -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) +int main() { - jit_begin(j, arena_base, arena_size); - size_t align = jit_enter_jit_abi(j, 0, 0, 0); - jit_load_args_1(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_FPR(0, EJIT_TYPE(double)) + }; + struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands); - jit_negr_f(j, JIT_F0, JIT_F0); - jit_leave_jit_abi(j, 0, 0, align); - jit_retr_f(j, JIT_F0); + ejit_negr_f(f, EJIT_FPR(0), EJIT_FPR(0)); + ejit_retr_f(f, EJIT_FPR(0)); - float (*f)(float) = jit_end(j, NULL); + ejit_select_compile_func(f, 0, 1, EJIT_USE64(double), do_jit); - ASSERT(f(0.0f) == -0.0f); - ASSERT(f(0.5f) == -0.5f); - ASSERT(f(1.0f / 0.0f) == -1.0f / 0.0f); - ASSERT(f(-1.25f) == 1.25f); -} + assert(erff1(f, EJIT_ARG(0.0f, double)) == -0.0f); + assert(erff1(f, EJIT_ARG(0.5f, double)) == -0.5f); + assert(erff1(f, EJIT_ARG(1.0f / 0.0f, double)) == -1.0f / 0.0f); + assert(erff1(f, EJIT_ARG(-1.25f, double)) == 1.25f); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_destroy_func(f); } -- cgit v1.2.3