mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
add additional tests for https://github.com/jekyll/jekyll/pull/2505
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ThingWithValue < Liquid::Drop
|
||||||
|
def value
|
||||||
|
3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class ForTagTest < Test::Unit::TestCase
|
class ForTagTest < Test::Unit::TestCase
|
||||||
include Liquid
|
include Liquid
|
||||||
|
|
||||||
@@ -34,6 +40,20 @@ HERE
|
|||||||
assert_template_result(' 1 2 3 ','{%for item in (1..3) %} {{item}} {%endfor%}')
|
assert_template_result(' 1 2 3 ','{%for item in (1..3) %} {{item}} {%endfor%}')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_for_with_variable_range
|
||||||
|
assert_template_result(' 1 2 3 ','{%for item in (1..foobar) %} {{item}} {%endfor%}', "foobar" => 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_for_with_hash_value_range
|
||||||
|
foobar = { "value" => 3 }
|
||||||
|
assert_template_result(' 1 2 3 ','{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_for_with_drop_value_range
|
||||||
|
foobar = ThingWithValue.new
|
||||||
|
assert_template_result(' 1 2 3 ','{%for item in (1..foobar.value) %} {{item}} {%endfor%}', "foobar" => foobar)
|
||||||
|
end
|
||||||
|
|
||||||
def test_for_with_variable
|
def test_for_with_variable
|
||||||
assert_template_result(' 1 2 3 ','{%for item in array%} {{item}} {%endfor%}','array' => [1,2,3])
|
assert_template_result(' 1 2 3 ','{%for item in array%} {{item}} {%endfor%}','array' => [1,2,3])
|
||||||
assert_template_result('123','{%for item in array%}{{item}}{%endfor%}','array' => [1,2,3])
|
assert_template_result('123','{%for item in array%}{{item}}{%endfor%}','array' => [1,2,3])
|
||||||
|
|||||||
Reference in New Issue
Block a user