forked from cory/tildefriends
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:
parent
843c53e15e
commit
786c83c57c
28
src/tests.c
28
src/tests.c
@ -33,8 +33,10 @@ static void _test_child(const tf_test_options_t* options)
|
|||||||
" print('child exited');\n"
|
" print('child exited');\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"task.activate();\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"
|
" print('child started');\n"
|
||||||
|
" });\n"
|
||||||
"});");
|
"});");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -62,7 +64,8 @@ static void _test_promise(const tf_test_options_t* options)
|
|||||||
fprintf(file,
|
fprintf(file,
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\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"
|
" task.getExports().then(function(exports) {\n"
|
||||||
" return exports.add(1, 1);\n"
|
" return exports.add(1, 1);\n"
|
||||||
" }).then(function(sum) {\n"
|
" }).then(function(sum) {\n"
|
||||||
@ -72,6 +75,7 @@ static void _test_promise(const tf_test_options_t* options)
|
|||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -102,7 +106,8 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
|
|||||||
fprintf(file,
|
fprintf(file,
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\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"
|
" task.getExports().then(function(exp) {\n"
|
||||||
" return exp.add(1, 1);\n"
|
" return exp.add(1, 1);\n"
|
||||||
" }).then(function(sum) {\n"
|
" }).then(function(sum) {\n"
|
||||||
@ -114,8 +119,9 @@ static void _test_promise_remote_throw(const tf_test_options_t* options)
|
|||||||
" }\n"
|
" }\n"
|
||||||
" exit(0);\n"
|
" exit(0);\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"}).catch(function(e) {\n"
|
" }).catch(function(e) {\n"
|
||||||
" print('caught', e.message);\n"
|
" print('caught', e.message);\n"
|
||||||
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -146,7 +152,8 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
|
|||||||
fprintf(file,
|
fprintf(file,
|
||||||
"var task = new Task();\n"
|
"var task = new Task();\n"
|
||||||
"task.activate();\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"
|
" task.getExports().then(function(exp) {\n"
|
||||||
" return exp.add(1, 1);\n"
|
" return exp.add(1, 1);\n"
|
||||||
" }).then(function(sum) {\n"
|
" }).then(function(sum) {\n"
|
||||||
@ -158,8 +165,9 @@ static void _test_promise_remote_reject(const tf_test_options_t* options)
|
|||||||
" }\n"
|
" }\n"
|
||||||
" exit(0);\n"
|
" exit(0);\n"
|
||||||
" });\n"
|
" });\n"
|
||||||
"}).catch(function(e) {\n"
|
" }).catch(function(e) {\n"
|
||||||
" print('caught', e.message);\n"
|
" print('caught', e.message);\n"
|
||||||
|
" });\n"
|
||||||
"});\n");
|
"});\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -259,7 +267,7 @@ static void _test_await(const tf_test_options_t* options)
|
|||||||
"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"
|
||||||
" });\n"
|
" });\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
@ -375,7 +383,8 @@ static void _test_uint8array(const tf_test_options_t* options)
|
|||||||
" print('child exited');\n"
|
" print('child exited');\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"task.activate();\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"
|
" print('child started');\n"
|
||||||
" var input = new Uint8Array(10);\n"
|
" var input = new Uint8Array(10);\n"
|
||||||
" for (var i = 0; i < 10; i++) {\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"
|
||||||
" }\n"
|
" }\n"
|
||||||
" exit(0);\n"
|
" exit(0);\n"
|
||||||
"});\n");
|
" })\n"
|
||||||
|
"})\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
file = fopen("out/child.js", "w");
|
file = fopen("out/child.js", "w");
|
||||||
|
Loading…
Reference in New Issue
Block a user