Optimized repeat and its tests

This commit is contained in:
Demian Ferreiro
2013-02-26 14:41:01 -03:00
parent fbc8417263
commit 1db89d1589
3 changed files with 29 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
# -------
# pull the helpers from `CoffeeScript.helpers` into local variables
{starts, ends, compact, count, merge, extend, flatten, del, last} = CoffeeScript.helpers
{starts, ends, repeat, compact, count, merge, extend, flatten, del, last} = CoffeeScript.helpers
# `starts`
@@ -27,6 +27,15 @@ test "the `ends` helper can take an optional offset", ->
ok not ends('01234', '234', 6)
# `repeat`
test "the `repeat` helper concatenates a given number of times", ->
eq 'asdasdasd', repeat('asd', 3)
test "`repeat`ing a string 0 times always returns the empty string", ->
eq '', repeat('whatever', 0)
# `compact`
test "the `compact` helper removes falsey values from an array, preserves truthy ones", ->