Appease gcc 12's analyzer.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4740 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d5ede43a13
commit
21d4a9b328
@ -244,7 +244,8 @@ $(APP_OBJS): CFLAGS += \
|
|||||||
-Werror
|
-Werror
|
||||||
ifeq ($(UNAME_M),x86_64)
|
ifeq ($(UNAME_M),x86_64)
|
||||||
$(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos% $(BUILD_DIR)/ios%,$(APP_OBJS)): CFLAGS += \
|
$(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos% $(BUILD_DIR)/ios%,$(APP_OBJS)): CFLAGS += \
|
||||||
-fanalyzer
|
-fanalyzer #\
|
||||||
|
#-Wno-analyzer-use-of-uninitialized-value
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BLOWFISH_SOURCES := \
|
BLOWFISH_SOURCES := \
|
||||||
|
@ -563,9 +563,10 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback(tf_ssb_connection_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSPropertyEnum* ptab;
|
JSPropertyEnum* ptab = NULL;
|
||||||
uint32_t plen;
|
uint32_t plen = 0;
|
||||||
JS_GetOwnPropertyNames(context, &ptab, &plen, args, JS_GPN_STRING_MASK);
|
if (JS_GetOwnPropertyNames(context, &ptab, &plen, args, JS_GPN_STRING_MASK) == 0)
|
||||||
|
{
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
||||||
@ -630,6 +631,7 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback(tf_ssb_connection_
|
|||||||
}
|
}
|
||||||
js_free(context, ptab);
|
js_free(context, ptab);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_rpc_connection_room_attendants_callback(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
static void _tf_ssb_rpc_connection_room_attendants_callback(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
||||||
{
|
{
|
||||||
@ -1007,24 +1009,34 @@ static void _tf_ssb_rpc_ebt_replicate_send_clock(tf_ssb_connection_t* connection
|
|||||||
|
|
||||||
if (!JS_IsUndefined(message))
|
if (!JS_IsUndefined(message))
|
||||||
{
|
{
|
||||||
JSPropertyEnum* ptab;
|
JSPropertyEnum* ptab = NULL;
|
||||||
uint32_t plen = 0;
|
uint32_t plen = 0;
|
||||||
JS_GetOwnPropertyNames(context, &ptab, &plen, message, JS_GPN_STRING_MASK);
|
if (JS_GetOwnPropertyNames(context, &ptab, &plen, message, JS_GPN_STRING_MASK) == 0)
|
||||||
|
{
|
||||||
work->clock_count = (int)plen;
|
work->clock_count = (int)plen;
|
||||||
work->clock = tf_malloc(sizeof(ebt_clock_row_t) * plen);
|
work->clock = tf_malloc(sizeof(ebt_clock_row_t) * plen);
|
||||||
|
memset(work->clock, 0, sizeof(ebt_clock_row_t) * plen);
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
{
|
{
|
||||||
const char* id = JS_AtomToCString(context, ptab[i].atom);
|
const char* id = JS_AtomToCString(context, ptab[i].atom);
|
||||||
snprintf(work->clock[i].id, sizeof(work->clock[i].id), "%s", id);
|
snprintf(work->clock[i].id, sizeof(work->clock[i].id), "%s", id);
|
||||||
JS_FreeCString(context, id);
|
JS_FreeCString(context, id);
|
||||||
|
|
||||||
JSValue value = JS_GetProperty(context, message, ptab[i].atom);
|
JSPropertyDescriptor desc = { 0 };
|
||||||
JS_ToInt64(context, &work->clock[i].value, value);
|
JSValue key_value = JS_UNDEFINED;
|
||||||
JS_FreeValue(context, value);
|
if (JS_GetOwnProperty(context, &desc, message, ptab[i].atom) == 1)
|
||||||
|
{
|
||||||
|
key_value = desc.value;
|
||||||
|
JS_FreeValue(context, desc.setter);
|
||||||
|
JS_FreeValue(context, desc.getter);
|
||||||
|
}
|
||||||
|
JS_ToInt64(context, &work->clock[i].value, key_value);
|
||||||
|
JS_FreeValue(context, key_value);
|
||||||
JS_FreeAtom(context, ptab[i].atom);
|
JS_FreeAtom(context, ptab[i].atom);
|
||||||
}
|
}
|
||||||
js_free(context, ptab);
|
js_free(context, ptab);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tf_ssb_connection_run_work(connection, _tf_ssb_rpc_ebt_replicate_send_clock_work, _tf_ssb_rpc_ebt_replicate_send_clock_after_work, work);
|
tf_ssb_connection_run_work(connection, _tf_ssb_rpc_ebt_replicate_send_clock_work, _tf_ssb_rpc_ebt_replicate_send_clock_after_work, work);
|
||||||
}
|
}
|
||||||
@ -1040,10 +1052,18 @@ static void _tf_ssb_rpc_ebt_replicate_send_messages(tf_ssb_connection_t* connect
|
|||||||
JSContext* context = tf_ssb_get_context(ssb);
|
JSContext* context = tf_ssb_get_context(ssb);
|
||||||
JSPropertyEnum* ptab = NULL;
|
JSPropertyEnum* ptab = NULL;
|
||||||
uint32_t plen = 0;
|
uint32_t plen = 0;
|
||||||
JS_GetOwnPropertyNames(context, &ptab, &plen, message, JS_GPN_STRING_MASK);
|
if (JS_GetOwnPropertyNames(context, &ptab, &plen, message, JS_GPN_STRING_MASK) == 0)
|
||||||
|
{
|
||||||
for (uint32_t i = 0; i < plen; ++i)
|
for (uint32_t i = 0; i < plen; ++i)
|
||||||
{
|
{
|
||||||
JSValue in_clock = JS_GetProperty(context, message, ptab[i].atom);
|
JSValue in_clock = JS_UNDEFINED;
|
||||||
|
JSPropertyDescriptor desc = { 0 };
|
||||||
|
if (JS_GetOwnProperty(context, &desc, message, ptab[i].atom) == 1)
|
||||||
|
{
|
||||||
|
in_clock = desc.value;
|
||||||
|
JS_FreeValue(context, desc.setter);
|
||||||
|
JS_FreeValue(context, desc.getter);
|
||||||
|
}
|
||||||
if (!JS_IsUndefined(in_clock))
|
if (!JS_IsUndefined(in_clock))
|
||||||
{
|
{
|
||||||
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
JSValue key = JS_AtomToString(context, ptab[i].atom);
|
||||||
@ -1071,6 +1091,7 @@ static void _tf_ssb_rpc_ebt_replicate_send_messages(tf_ssb_connection_t* connect
|
|||||||
}
|
}
|
||||||
js_free(context, ptab);
|
js_free(context, ptab);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data)
|
||||||
{
|
{
|
||||||
|
139
src/tests.c
139
src/tests.c
@ -30,11 +30,22 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TARGET_OS_IPHONE
|
#if !TARGET_OS_IPHONE
|
||||||
static void _test_nop(const tf_test_options_t* options)
|
static void _write_file(const char* path, const char* contents)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
FILE* file = fopen("out/test.js", "w");
|
||||||
fprintf(file, "print('hi');");
|
if (!file)
|
||||||
|
{
|
||||||
|
printf("Unable to write %s: %s.\n", path, strerror(errno));
|
||||||
|
fflush(stdout);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
fputs(contents, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _test_nop(const tf_test_options_t* options)
|
||||||
|
{
|
||||||
|
_write_file("out/test.js", "print('hi');");
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -47,8 +58,8 @@ static void _test_nop(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_child(const tf_test_options_t* options)
|
static void _test_child(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.onExit = function() {\n"
|
"task.onExit = function() {\n"
|
||||||
" print('child exited');\n"
|
" print('child exited');\n"
|
||||||
@ -59,13 +70,11 @@ static void _test_child(const tf_test_options_t* options)
|
|||||||
" print('child started');\n"
|
" print('child started');\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"});");
|
"});");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"print('I am the child process.');\n"
|
"print('I am the child process.');\n"
|
||||||
"exit(0);\n");
|
"exit(0);\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -81,8 +90,7 @@ static void _test_child(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_promise(const tf_test_options_t* options)
|
static void _test_promise(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file("out/test.js",
|
||||||
fprintf(file,
|
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\n"
|
"task.activate();\n"
|
||||||
"File.readFile('out/child.js').then(function(data) {\n"
|
"File.readFile('out/child.js').then(function(data) {\n"
|
||||||
@ -98,16 +106,14 @@ static void _test_promise(const tf_test_options_t* options)
|
|||||||
" });\n"
|
" });\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"exports = {\n"
|
"exports = {\n"
|
||||||
" add: function(left, right) {\n"
|
" add: function(left, right) {\n"
|
||||||
" return left + right;\n"
|
" return left + right;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -123,8 +129,8 @@ static void _test_promise(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_promise_remote_throw(const tf_test_options_t* options)
|
static void _test_promise_remote_throw(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\n"
|
"task.activate();\n"
|
||||||
"File.readFile('out/child.js').then(function(data) {\n"
|
"File.readFile('out/child.js').then(function(data) {\n"
|
||||||
@ -144,16 +150,14 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
|
|||||||
" print('caught', e.message);\n"
|
" print('caught', e.message);\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"exports = {\n"
|
"exports = {\n"
|
||||||
" add: function(left, right) {\n"
|
" add: function(left, right) {\n"
|
||||||
" throw new Error('fail');\n"
|
" throw new Error('fail');\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -169,8 +173,8 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_promise_remote_reject(const tf_test_options_t* options)
|
static void _test_promise_remote_reject(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\n"
|
"task.activate();\n"
|
||||||
"File.readFile('out/child.js').then(function(data) {\n"
|
"File.readFile('out/child.js').then(function(data) {\n"
|
||||||
@ -190,10 +194,9 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
|
|||||||
" print('caught', e.message);\n"
|
" print('caught', e.message);\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"exports = {\n"
|
"exports = {\n"
|
||||||
" add: function(left, right) {\n"
|
" add: function(left, right) {\n"
|
||||||
" return new Promise(function(resolve, reject) {\n"
|
" return new Promise(function(resolve, reject) {\n"
|
||||||
@ -201,7 +204,6 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
|
|||||||
" });\n"
|
" });\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -217,8 +219,8 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_database(const tf_test_options_t* options)
|
static void _test_database(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var db = new Database('testdb');\n"
|
"var db = new Database('testdb');\n"
|
||||||
"if (db.get('a')) {\n"
|
"if (db.get('a')) {\n"
|
||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
@ -245,7 +247,6 @@ static void _test_database(const tf_test_options_t* options)
|
|||||||
" print('Expected but did not find: ' + JSON.stringify(expected));\n"
|
" print('Expected but did not find: ' + JSON.stringify(expected));\n"
|
||||||
" exit(4);\n"
|
" exit(4);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
unlink("out/test_db0.sqlite");
|
unlink("out/test_db0.sqlite");
|
||||||
@ -262,12 +263,11 @@ static void _test_database(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_this(const tf_test_options_t* options)
|
static void _test_this(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate.bind(null).apply();\n"
|
"task.activate.bind(null).apply();\n"
|
||||||
"exit(0);\n");
|
"exit(0);\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -282,10 +282,9 @@ static void _test_this(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_await(const tf_test_options_t* options)
|
static void _test_await(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"print('hi');\n"
|
"print('hi');\n"
|
||||||
|
|
||||||
"function foobar() {\n"
|
"function foobar() {\n"
|
||||||
" return new Promise(function(resolve, reject) {\n"
|
" return new Promise(function(resolve, reject) {\n"
|
||||||
" resolve(10);\n"
|
" resolve(10);\n"
|
||||||
@ -300,7 +299,6 @@ static void _test_await(const tf_test_options_t* options)
|
|||||||
" }\n"
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n");
|
"\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -315,28 +313,25 @@ static void _test_await(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_import(const tf_test_options_t* options)
|
static void _test_import(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"import * as req from './required.js';\n"
|
"import * as req from './required.js';\n"
|
||||||
"if (req.foo() != 12345) {\n"
|
"if (req.foo() != 12345) {\n"
|
||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/required.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/required.js",
|
||||||
"export function foo() {\n"
|
"export function foo() {\n"
|
||||||
" return 12345;\n"
|
" return 12345;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/bad.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/bad.js",
|
||||||
"import * as req from './missing.js';\n"
|
"import * as req from './missing.js';\n"
|
||||||
"if (req.foo() != 12345) {\n"
|
"if (req.foo() != 12345) {\n"
|
||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -360,13 +355,8 @@ static void _test_import(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_exit(const tf_test_options_t* options)
|
static void _test_exit(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file("out/test.js", "import * as blah from './blah.js';\n");
|
||||||
fprintf(file, "import * as blah from './blah.js';\n");
|
_write_file("out/blah.js", "\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/blah.js", "w");
|
|
||||||
fprintf(file, "\n");
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -382,11 +372,10 @@ static void _test_exit(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_icu(const tf_test_options_t* options)
|
static void _test_icu(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"print('Hi');\n"
|
"print('Hi');\n"
|
||||||
"print(parseInt('3').toLocaleString());\n");
|
"print(parseInt('3').toLocaleString());\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -401,8 +390,8 @@ static void _test_icu(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_uint8array(const tf_test_options_t* options)
|
static void _test_uint8array(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.onExit = function() {\n"
|
"task.onExit = function() {\n"
|
||||||
" print('child exited');\n"
|
" print('child exited');\n"
|
||||||
@ -429,16 +418,14 @@ static void _test_uint8array(const tf_test_options_t* options)
|
|||||||
" exit(0);\n"
|
" exit(0);\n"
|
||||||
" })\n"
|
" })\n"
|
||||||
"})\n");
|
"})\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"exports = {\n"
|
"exports = {\n"
|
||||||
" test: function(data) {\n"
|
" test: function(data) {\n"
|
||||||
" return data;\n"
|
" return data;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -454,8 +441,8 @@ static void _test_uint8array(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_float(const tf_test_options_t* options)
|
static void _test_float(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.onExit = function() {\n"
|
"task.onExit = function() {\n"
|
||||||
" print('child exited');\n"
|
" print('child exited');\n"
|
||||||
@ -471,10 +458,9 @@ static void _test_float(const tf_test_options_t* options)
|
|||||||
" exit(result == 1.2 ? 0 : 1);\n"
|
" exit(result == 1.2 ? 0 : 1);\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"});");
|
"});");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/child.js",
|
||||||
"print(\"child\");\n"
|
"print(\"child\");\n"
|
||||||
"exports = {\n"
|
"exports = {\n"
|
||||||
" test: function(value) {\n"
|
" test: function(value) {\n"
|
||||||
@ -484,7 +470,6 @@ static void _test_float(const tf_test_options_t* options)
|
|||||||
"};\n"
|
"};\n"
|
||||||
"print(\"child ready\");\n"
|
"print(\"child ready\");\n"
|
||||||
);
|
);
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -500,8 +485,8 @@ static void _test_float(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_socket(const tf_test_options_t* options)
|
static void _test_socket(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"'use strict';\n"
|
"'use strict';\n"
|
||||||
"\n"
|
"\n"
|
||||||
"var s = new Socket();\n"
|
"var s = new Socket();\n"
|
||||||
@ -573,7 +558,6 @@ static void _test_socket(const tf_test_options_t* options)
|
|||||||
" print('caught');\n"
|
" print('caught');\n"
|
||||||
" print(e);\n"
|
" print(e);\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -588,8 +572,8 @@ static void _test_socket(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_file(const tf_test_options_t* options)
|
static void _test_file(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"'use strict';\n"
|
"'use strict';\n"
|
||||||
"File.readFile('out/test.js').then(function(data) {\n"
|
"File.readFile('out/test.js').then(function(data) {\n"
|
||||||
"}).catch(function(error) {\n"
|
"}).catch(function(error) {\n"
|
||||||
@ -602,7 +586,6 @@ static void _test_file(const tf_test_options_t* options)
|
|||||||
"}).catch(function(error) {\n"
|
"}).catch(function(error) {\n"
|
||||||
" print('expected error', error);\n"
|
" print('expected error', error);\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -617,8 +600,8 @@ static void _test_file(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_sign(const tf_test_options_t* options)
|
static void _test_sign(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"'use strict';\n"
|
"'use strict';\n"
|
||||||
"let id = ssb.createIdentity('test');\n"
|
"let id = ssb.createIdentity('test');\n"
|
||||||
"print(id);\n"
|
"print(id);\n"
|
||||||
@ -634,7 +617,6 @@ static void _test_sign(const tf_test_options_t* options)
|
|||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
@ -649,8 +631,8 @@ static void _test_sign(const tf_test_options_t* options)
|
|||||||
|
|
||||||
static void _test_b64(const tf_test_options_t* options)
|
static void _test_b64(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
_write_file(
|
||||||
fprintf(file,
|
"out/test.js",
|
||||||
"'use strict';\n"
|
"'use strict';\n"
|
||||||
"print(base64Encode('hello'));\n"
|
"print(base64Encode('hello'));\n"
|
||||||
"let x = utf8Decode(base64Decode(base64Encode('hello')));\n"
|
"let x = utf8Decode(base64Decode(base64Encode('hello')));\n"
|
||||||
@ -659,7 +641,6 @@ static void _test_b64(const tf_test_options_t* options)
|
|||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
char command[256];
|
char command[256];
|
||||||
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
snprintf(command, sizeof(command), "%s run --ssb-port=0 --db-path=:memory: -s out/test.js", options->exe_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user