Merge branch 'fix_reduceRight_initial_value' of http://github.com/mcmire/underscore

This commit is contained in:
Jeremy Ashkenas
2010-11-01 08:42:19 -04:00
2 changed files with 11 additions and 3 deletions

View File

@@ -71,8 +71,14 @@ $(document).ready(function() {
});
test('collections: reduceRight', function() {
var list = _.foldr([1, 2, 3], function(memo, num){ return memo + num; }, '');
equals(list, '321', 'can perform right folds');
var list = _.reduceRight(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
equals(list, 'bazbarfoo', 'can perform right folds');
var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
equals(list, 'bazbarfoo', 'aliased as "foldr"');
var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; });
equals(list, 'bazbarfoo', 'default initial value');
});
test('collections: detect', function() {