add more legacy tests

This commit is contained in:
Florian Weingarten
2014-07-24 00:33:39 +00:00
parent b7b243a13d
commit 0b45ffeada
2 changed files with 33 additions and 12 deletions

View File

@@ -92,7 +92,7 @@ module Liquid
# Join elements of the array with certain character between them
def join(input, glue = ' '.freeze)
Array(input).join(glue)
InputIterator.new(input).join(glue)
end
# Sort elements of the array
@@ -110,7 +110,7 @@ module Liquid
# Reverse the elements of an array
def reverse(input)
ary = Array(input)
ary = InputIterator.new(input)
ary.reverse
end
@@ -309,16 +309,23 @@ module Liquid
include Enumerable
def initialize(input)
@input =
if input.is_a?(Array)
input.flatten
elsif input.is_a?(Hash)
[input]
elsif input.is_a?(Enumerable)
input
else
Array(input)
end
@input = if input.is_a?(Array)
input.flatten
elsif input.is_a?(Hash)
[input]
elsif input.is_a?(Enumerable)
input
else
Array(input)
end
end
def join(glue)
to_a.join(glue)
end
def reverse
reverse_each.to_a
end
def each