aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-08-27 20:33:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-08-27 20:33:54 -0700
commit4499c52fcaa709466520f6224fbe7414cfa246d7 (patch)
tree16f6cc8b875417336363a1af2350b25d9baa69ac
parent58a2ec60c63b0179b5fa215af1934fe297356f7d (diff)
clean up atoX a little and add testing
-rw-r--r--src/library.js10
-rwxr-xr-xtests/runner.py29
2 files changed, 28 insertions, 11 deletions
diff --git a/src/library.js b/src/library.js
index 6a94be40..0eefea84 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3715,25 +3715,17 @@ LibraryManager.library = {
atof__deps: ['strtod'],
atof: function(ptr) {
- var str = Pointer_stringify(ptr);
return _strtod(ptr, null);
},
atoi__deps: ['strtol'],
atoi: function(ptr) {
- var str = Pointer_stringify(ptr);
- return _strtol(ptr, null, 10);
- },
-
- atol__deps: ['strtol'],
- atol: function(ptr) {
- var str = Pointer_stringify(ptr);
return _strtol(ptr, null, 10);
},
+ atol: 'atoi',
atoll__deps: ['strtoll'],
atoll: function(ptr) {
- var str = Pointer_stringify(ptr);
return _strtoll(ptr, null, 10);
},
diff --git a/tests/runner.py b/tests/runner.py
index 7f573952..563f6bc1 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -4022,7 +4022,9 @@ at function.:blag
'''
self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
- def test_atoi(self):
+ def test_atoX(self):
+ if Settings.QUANTUM_SIZE != 4: return self.skip('need q4 for atoll')
+
src = r'''
#include <stdio.h>
#include <stdlib.h>
@@ -4039,10 +4041,33 @@ at function.:blag
printf("%d*", atoi(" 3 7"));
printf("%d*", atoi("9 d"));
printf("%d\n", atoi(" 8 e"));
+ printf("%d*", atol(""));
+ printf("%d*", atol("a"));
+ printf("%d*", atol(" b"));
+ printf("%d*", atol(" c "));
+ printf("%d*", atol("6"));
+ printf("%d*", atol(" 5"));
+ printf("%d*", atol("4 "));
+ printf("%d*", atol("3 6"));
+ printf("%d*", atol(" 3 7"));
+ printf("%d*", atol("9 d"));
+ printf("%d\n", atol(" 8 e"));
+ printf("%lld*", atoll("6294967296"));
+ printf("%lld*", atoll(""));
+ printf("%lld*", atoll("a"));
+ printf("%lld*", atoll(" b"));
+ printf("%lld*", atoll(" c "));
+ printf("%lld*", atoll("6"));
+ printf("%lld*", atoll(" 5"));
+ printf("%lld*", atoll("4 "));
+ printf("%lld*", atoll("3 6"));
+ printf("%lld*", atoll(" 3 7"));
+ printf("%lld*", atoll("9 d"));
+ printf("%lld\n", atoll(" 8 e"));
return 0;
}
'''
- self.do_run(src, '0*0*0*0*6*5*4*3*3*9*8')
+ self.do_run(src, '0*0*0*0*6*5*4*3*3*9*8\n0*0*0*0*6*5*4*3*3*9*8\n6294967296*0*0*0*0*6*5*4*3*3*9*8\n')
def test_strstr(self):
src = r'''