diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-13 18:57:41 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-13 18:57:41 -0700 |
commit | b5e53f4e1759ad04d2d1fcd841c1164ceab4364c (patch) | |
tree | 891320d479366f8a02fc4f82c90fb5c2f75771e9 /tests | |
parent | 02b5bd72bd7b4248d0f57595f511a7371f836ae4 (diff) |
--js-library option to make it easy to add additional library_*.js files
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 7c24c799..a565b1d2 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6396,6 +6396,38 @@ f.close() Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), os.path.join(self.get_dir(), 'subdir', 'libfile.so'), '-L.']).communicate() self.assertContained('hello from lib', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_js_libraries(self): + open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(''' + #include <stdio.h> + extern "C" { + extern void printey(); + extern int calcey(int x, int y); + } + int main() { + printey(); + printf("*%d*\\n", calcey(10, 22)); + return 0; + } + ''') + open(os.path.join(self.get_dir(), 'mylib1.js'), 'w').write(''' + mergeInto(LibraryManager.library, { + printey: function() { + Module.print('hello from lib!'); + } + }); + ''') + open(os.path.join(self.get_dir(), 'mylib2.js'), 'w').write(''' + mergeInto(LibraryManager.library, { + calcey: function(x, y) { + return x + y; + } + }); + ''') + + Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--js-library', os.path.join(self.get_dir(), 'mylib1.js'), + '--js-library', os.path.join(self.get_dir(), 'mylib2.js')]).communicate() + self.assertContained('hello from lib!\n*32*\n', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_identical_basenames(self): # Issue 287: files in different dirs but with the same basename get confused as the same, # causing multiply defined symbol errors |