aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-10 16:04:00 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-10 16:04:00 -0700
commite4c7ddc813f9376f62c47560bec4b1c1a8974070 (patch)
treea89d1a645ba37ed2c948fa08c72b4606762106c0
parentab38fa9479fd553d493170e447f486e7838091cc (diff)
parent21043de9613fc4d1fa948c344a0dc93b88e6cb15 (diff)
Merge pull request #2412 from juj/test_js_libraries_in_core
Test js libraries in core
-rw-r--r--tests/test_core.py33
-rw-r--r--tests/test_other.py32
2 files changed, 33 insertions, 32 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index 38d2f027..13b6c0f3 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4652,6 +4652,39 @@ PORT: 3979
'''
self.do_run(src, 'value\narray_item1\narray_item2\narray_item3\n3\n3.00\n2.20\nJansson: Node with ID `0` not found. Context has `10` nodes.\n0\nJansson: No JSON context.\njansson!')
+ def test_js_libraries(self):
+ if self.emcc_args == None: return self.skip('needs emcc')
+
+ 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;
+ }
+ });
+ ''')
+
+ self.emcc_args += ['--js-library', os.path.join(self.get_dir(), 'mylib1.js'), '--js-library', os.path.join(self.get_dir(), 'mylib2.js')]
+ self.do_run(open(os.path.join(self.get_dir(), 'main.cpp'), 'r').read(), 'hello from lib!\n*32*\n')
+
def test_constglobalunion(self):
if self.emcc_args is None: return self.skip('needs emcc')
self.emcc_args += ['-s', 'EXPORT_ALL=1']
diff --git a/tests/test_other.py b/tests/test_other.py
index 39796b71..6e04ead5 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -1306,38 +1306,6 @@ This pointer might make sense in another type signature: i: 0
self.assertContained('TestA\nTestB\nTestA\n', run_js('main.js', engine=SPIDERMONKEY_ENGINE))
- 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