aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-08-10 10:30:10 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-08-10 10:33:40 -0700
commit9998978f1bc0c0aafeac29dd7adf5b2b0b6e078e (patch)
tree07d5c987fca78667e42a66a885ae116da58fbef7 /tests/runner.py
parentb3389d30aaf4fecb9749ebffa4577b140c570fde (diff)
Module.preInit
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index c6c7cb2c..70f7ba9d 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7259,6 +7259,17 @@ f.close()
open(os.path.join(self.get_dir(), 'a.out.js'), 'w').write(src)
assert 'hello from main' in run_js(os.path.join(self.get_dir(), 'a.out.js')), 'main should print when called manually'
+ # Use postInit
+ open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
+ var Module = {
+ preRun: function() { Module.print('pre-run') },
+ postRun: function() { Module.print('post-run') },
+ preInit: function() { Module.print('pre-init') }
+ };
+ ''')
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'pre.js']).communicate()
+ self.assertContained('pre-init\npre-run\nhello from main\npost-run\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_prepost2(self):
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write('''
#include <stdio.h>