diff options
author | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2014-04-24 08:41:41 +0100 |
---|---|---|
committer | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2014-04-24 08:41:41 +0100 |
commit | e59333c486a97132698a1232ffdb1f5ae048d2b6 (patch) | |
tree | d068317527d5bfe435348172f6f2a76cfc0dfb18 /tests/test_core.py | |
parent | 55ba58508e65f70aed38ec57b78b46a83ecf9433 (diff) |
Committing the actual change now
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index 1b116c4a..97462cf9 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6499,6 +6499,28 @@ def process(filename): if self.emcc_args is None: return self.skip('needs emcc') self.do_run_from_file(path_from_root('tests', 'test_locale.c'), path_from_root('tests', 'test_locale.out')) + def test_64bit_return_value(self): + # This test checks that the most significant 32 bits of a 64 bit long are correctly made available + # to native JavaScript applications that wish to interact with compiled code returning 64 bit longs. + # The MS 32 bits should be available in Runtime.getTempRet0() even when compiled with -O2 --closure 1 + # Run with ./runner.py test_64bit_return_value + + # Compile test.c and wrap it in a native JavaScript binding so we can call our compiled function from JS. + Popen([PYTHON, EMCC, path_from_root('tests', 'return64bit', 'test.c'), '--pre-js', path_from_root('tests', 'return64bit', 'testbindstart.js'), '--pre-js', path_from_root('tests', 'return64bit', 'testbind.js'), '--post-js', path_from_root('tests', 'return64bit', 'testbindend.js'), '-s', 'EXPORTED_FUNCTIONS=["_test"]', '-o', 'test.js', '-O2', '--closure', '1'], stdout=PIPE, stderr=PIPE).communicate() + + # Simple test program to load the test.js binding library and call the binding to the + # C function returning the 64 bit long. + open(os.path.join(self.get_dir(), 'testrun.js'), 'w').write(''' + var test = require("./test.js"); + test.runtest(); + ''') + + # Run the test and confirm the output is as expected. + if NODE_JS in JS_ENGINES: + out = run_js('testrun.js', engine=NODE_JS, full_output=True) + assert "low = 5678" in out + assert "high = 1234" in out + # Generate tests for everything def make_run(fullname, name=-1, compiler=-1, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None, env=None): |