Fix tests in light of async File.readFile.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3669 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2021-10-10 22:45:24 +00:00
parent 843c53e15e
commit 786c83c57c

View File

@ -33,8 +33,10 @@ static void _test_child(const tf_test_options_t* options)
" print('child exited');\n"
"};\n"
"task.activate();\n"
"task.execute({name: 'child.js', source: utf8Decode(File.readFile('out/child.js'))}).then(function() {\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(function() {\n"
" print('child started');\n"
" });\n"
"});");
fclose(file);
@ -62,7 +64,8 @@ static void _test_promise(const tf_test_options_t* options)
fprintf(file,
"var task = new Task();\n"
"task.activate();\n"
"task.execute({name: 'child.js', source: utf8Decode(File.readFile('out/child.js'))}).then(function() {\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(function() {\n"
" task.getExports().then(function(exports) {\n"
" return exports.add(1, 1);\n"
" }).then(function(sum) {\n"
@ -72,6 +75,7 @@ static void _test_promise(const tf_test_options_t* options)
" exit(1);\n"
" }\n"
" });\n"
" });\n"
"});\n");
fclose(file);
@ -102,7 +106,8 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
fprintf(file,
"var task = new Task();\n"
"task.activate();\n"
"task.execute({name: 'child.js', source: utf8Decode(File.readFile('out/child.js'))}).then(function() {\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(function() {\n"
" task.getExports().then(function(exp) {\n"
" return exp.add(1, 1);\n"
" }).then(function(sum) {\n"
@ -114,8 +119,9 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
" }\n"
" exit(0);\n"
" });\n"
"}).catch(function(e) {\n"
" }).catch(function(e) {\n"
" print('caught', e.message);\n"
" });\n"
"});\n");
fclose(file);
@ -146,7 +152,8 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
fprintf(file,
"var task = new Task();\n"
"task.activate();\n"
"task.execute({name: 'child.js', source: utf8Decode(File.readFile('out/child.js'))}).then(function() {\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(function() {\n"
" task.getExports().then(function(exp) {\n"
" return exp.add(1, 1);\n"
" }).then(function(sum) {\n"
@ -158,8 +165,9 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
" }\n"
" exit(0);\n"
" });\n"
"}).catch(function(e) {\n"
" }).catch(function(e) {\n"
" print('caught', e.message);\n"
" });\n"
"});\n");
fclose(file);
@ -259,7 +267,7 @@ static void _test_await(const tf_test_options_t* options)
"print('hi');\n"
"function foobar() {\n"
" return new Promise(function (resolve, reject) {\n"
" return new Promise(function(resolve, reject) {\n"
" resolve(10);\n"
" });\n"
"}\n"
@ -375,7 +383,8 @@ static void _test_uint8array(const tf_test_options_t* options)
" print('child exited');\n"
"};\n"
"task.activate();\n"
"task.execute({name: 'child.js', source: utf8Decode(File.readFile('out/child.js'))}).then(async function() {\n"
"File.readFile('out/child.js').then(function(data) {\n"
" task.execute({name: 'child.js', source: utf8Decode(data)}).then(async function() {\n"
" print('child started');\n"
" var input = new Uint8Array(10);\n"
" for (var i = 0; i < 10; i++) {\n"
@ -393,7 +402,8 @@ static void _test_uint8array(const tf_test_options_t* options)
" }\n"
" }\n"
" exit(0);\n"
"});\n");
" })\n"
"})\n");
fclose(file);
file = fopen("out/child.js", "w");