test: update tests

This commit is contained in:
2026-05-25 17:35:09 +01:00
parent 5e3439bc4a
commit 01cbcf712a
5 changed files with 16 additions and 11 deletions
+10 -7
View File
@@ -1,3 +1,4 @@
#include <fx/cstr.h>
#include <fx/reflection/function.h>
#include <fx/string.h>
#include <fx/value.h>
@@ -6,8 +7,8 @@
int main(int argc, const char **argv)
{
fx_value_type arg_types[] = {
FX_VALUE_TYPE_CSTR,
fx_type_id arg_types[] = {
FX_TYPE_CSTR,
};
fx_function *func = fx_function_create(
@@ -16,18 +17,20 @@ int main(int argc, const char **argv)
(fx_function_impl)printf,
arg_types,
1,
FX_VALUE_TYPE_INT);
FX_TYPE_INT);
fx_string *fmt = fx_string_create_from_cstr(
"Hello %s! You are number %lf\n");
fx_value args[] = {
FX_VALUE_CSTR("Hello %s! You are number %lf\n"),
FX_VALUE_CSTR("Jonh"),
FX_VALUE_DOUBLE(2.5),
FX_VALUE_OBJECT(fmt),
FX_CSTR("Jonh"),
FX_DOUBLE(2.5),
};
fx_function_bind(func, args, sizeof args / sizeof args[0]);
fx_value result = FX_VALUE_EMPTY;
int r = fx_function_invoke(func, NULL, 0, &result);
printf("%" PRIdPTR "\n", result.v_int);
printf("%d\n", result.v_int);
return 0;
}