aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/postamble.js1
-rw-r--r--src/preamble.js8
-rw-r--r--tests/runner.py4
3 files changed, 8 insertions, 5 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 7be5110d..8f1f6cb8 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -30,6 +30,7 @@ function run(args) {
__shutdownRuntime__();
}
}
+Module['run'] = run;
#if INVOKE_RUN
run(args);
diff --git a/src/preamble.js b/src/preamble.js
index ef29bf82..c895231f 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -230,8 +230,10 @@ function __shutdownRuntime__() {
// stdio.h
-// C-style: we work on ints on the HEAP.
function __formatString() {
+ function isFloatArg(type) {
+ return String.fromCharCode(type) in Runtime.set('f', 'e', 'g');
+ }
var cStyle = false;
var textIndex = arguments[0];
var argIndex = 1;
@@ -249,7 +251,7 @@ function __formatString() {
ret = _arguments[argIndex];
argIndex++;
} else {
- ret = (type === 'f' ? FHEAP : IHEAP)[argIndex];
+ ret = (isFloatArg(type) ? FHEAP : IHEAP)[argIndex];
argIndex += type === 'l'.charCodeAt(0) ? 8 : 4; // XXX hardcoded native sizes
}
return ret;
@@ -279,7 +281,7 @@ function __formatString() {
textIndex++;
next = IHEAP[textIndex+1];
}
- if (next == 'e'.charCodeAt(0) || next == 'g'.charCodeAt(0)) {
+ if (isFloatArg(next)) {
next = 'f'.charCodeAt(0); // no support for 'e'
}
if (['d', 'i', 'u', 'p', 'f'].indexOf(String.fromCharCode(next)) != -1) {
diff --git a/tests/runner.py b/tests/runner.py
index 0560cc5d..ecb1998b 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1248,8 +1248,8 @@ if 'benchmark' not in sys.argv:
global RELOOP; RELOOP = 0 # Too slow; we do care about typed arrays and OPTIMIZE though
global SAFE_HEAP; SAFE_HEAP = 0 # Has bitfields etc.
self.do_ll_test(path_from_root(['tests', 'python', 'python.ll']),
- 'hello python world!\n\n[0, 2, 4, 6]\n\n5\n',
- args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t'''],
+ 'hello python world!\n\n[0, 2, 4, 6]\n\n5\n\n5.470',
+ args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t; print '%f' % 5.47'''],
js_engines=[V8_ENGINE]) # script stack space exceeded in SpiderMonkey, TODO
### Test cases in separate files