Actually serialize doubles. Yikes.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4463 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-09-17 00:13:31 +00:00
parent b23b0ca239
commit e921b4a86a
3 changed files with 52 additions and 11 deletions

View File

@ -438,6 +438,52 @@ static void _test_uint8array(const tf_test_options_t* options)
unlink("out/child.js");
}
static void _test_float(const tf_test_options_t* options)
{
FILE* file = fopen("out/test.js", "w");
fprintf(file,
"var task = new Task();\n"
"task.onExit = function() {\n"
" print('child exited');\n"
"};\n"
"task.activate();\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(async function() {\n"
" print('get exports');\n"
" let test = (await task.getExports()).test;\n"
" print('calling export');\n"
" let result = await test(1.2);\n"
" print(result);\n"
" exit(result == 1.2 ? 0 : 1);\n"
" });\n"
"});");
fclose(file);
file = fopen("out/child.js", "w");
fprintf(file,
"print(\"child\");\n"
"exports = {\n"
" test: function(value) {\n"
" print(value);\n"
" return value;\n"
" }\n"
"};\n"
"print(\"child ready\");\n"
);
fclose(file);
char command[256];
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
tf_printf("%s\n", command);
int result = system(command);
(void)result;
assert(WIFEXITED(result));
assert(WEXITSTATUS(result) == 0);
unlink("out/test.js");
unlink("out/child.js");
}
static void _test_socket(const tf_test_options_t* options)
{
FILE* file = fopen("out/test.js", "w");
@ -664,6 +710,7 @@ void tf_tests(const tf_test_options_t* options)
_tf_test_run(options, "exit", _test_exit);
_tf_test_run(options, "icu", _test_icu);
_tf_test_run(options, "uint8array", _test_uint8array);
_tf_test_run(options, "float", _test_float);
_tf_test_run(options, "socket", _test_socket);
_tf_test_run(options, "file", _test_file);
_tf_test_run(options, "sign", _test_sign);