Ensure _.reduce works with string Objects in IE < 9.

Former-commit-id: 0ee3496e52f4c393900f37f03e451b8e4abba206
This commit is contained in:
John-David Dalton
2012-08-26 01:04:09 -07:00
parent 1c69d9213e
commit f460c77f2c
2 changed files with 25 additions and 1 deletions

View File

@@ -1115,6 +1115,30 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.reduce');
(function() {
_.each({
'literal': 'abc',
'object': Object('abc')
},
function(collection, key) {
test('should work with a string ' + key + ' for `collection` (test in IE < 9)', function() {
var args;
var actual = _.reduce(collection, function(accumulator, value) {
args || (args = slice.call(arguments));
return accumulator + value;
});
deepEqual(args, ['a', 'b', 1, collection]);
equal(actual, 'abc');
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.reduceRight');
(function() {