Add _.parseInt.

Former-commit-id: 0c0f10af3dc50a4d1b684523f19d02e423d738f5
This commit is contained in:
John-David Dalton
2013-02-27 08:03:08 -08:00
parent ba795639b4
commit 999aae0a33
11 changed files with 328 additions and 209 deletions

View File

@@ -210,6 +210,7 @@
'merge',
'omit',
'pairs',
'parseInt',
'pick',
'values'
];
@@ -291,6 +292,7 @@
'forOwn',
'isPlainObject',
'merge',
'parseInt',
'partialRight',
'runInContext'
]));

View File

@@ -1767,6 +1767,22 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.parseInt');
(function() {
test('should parse strings with leading zeros with a `radix` of 10 by default (test in Firefox and Opera)', function() {
equal(_.parseInt('08'), 8);
});
test('should internally use a radix of 10 if `radix` is `undefined` or `0`', function() {
equal(_.parseInt('10', 0), 10);
equal(_.parseInt('10'), 10);
equal(_.parseInt('10', undefined), 10);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('partial methods');
_.each(['partial', 'partialRight'], function(methodName) {