fix format bug with floats
This commit is contained in:
Родитель
6cd6131d08
Коммит
58e445e6e1
|
@ -30,6 +30,7 @@ function run(args) {
|
|||
__shutdownRuntime__();
|
||||
}
|
||||
}
|
||||
Module['run'] = run;
|
||||
|
||||
#if INVOKE_RUN
|
||||
run(args);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче