diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-06 11:41:41 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-06 11:42:43 -0800 |
commit | 20d5ffb5925d57a5facacce453d4643e8809929d (patch) | |
tree | 0fdfca1be241a1792ceaf5c275b674f744a313e2 /tests/test_browser.py | |
parent | 1ac8ea0859d91d86c23b5574bd0474887df1b96e (diff) |
add docs and testing for mem init file being async
Diffstat (limited to 'tests/test_browser.py')
-rw-r--r-- | tests/test_browser.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_browser.py b/tests/test_browser.py index dfb1ef69..7ffe56c8 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -1752,6 +1752,23 @@ void *getBindBuffer() { for mem in [0, 1]: self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js', '--memory-init-file', str(mem)]) + def test_mem_init(self): + open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' + function myJSCallback() { // called from main() + Module._note(1); + } + Module.preRun = function() { + addOnPreMain(function() { + Module._note(2); + }); + }; + ''') + open(os.path.join(self.get_dir(), 'post.js'), 'w').write(''' + Module._note(4); // this happens too early! and is overwritten when the mem init arrives + ''') + + self.btest('mem_init.cpp', expected='3', args=['--pre-js', 'pre.js', '--post-js', 'post.js', '--memory-init-file', '1']) + def test_worker_api(self): Popen([PYTHON, EMCC, path_from_root('tests', 'worker_api_worker.cpp'), '-o', 'worker.js', '-s', 'BUILD_AS_WORKER=1', '-s', 'EXPORTED_FUNCTIONS=["_one"]']).communicate() self.btest('worker_api_main.cpp', expected='566') |