Compare commits

...

3 Commits

Author SHA1 Message Date
Peter Zhu
e98bb0d594 Use branch of liquid-c 2020-11-13 09:29:26 -05:00
Peter Zhu
76dbb0d640 Support float in variable range 2020-11-13 09:29:09 -05:00
Peter Zhu
eab12e1240 Test range of floats 2020-11-13 09:26:34 -05:00
4 changed files with 4 additions and 2 deletions

View File

@@ -22,6 +22,6 @@ group :test do
gem 'rubocop-performance', require: false
platform :mri, :truffleruby do
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'master'
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'pz-range-var-float'
end
end

View File

@@ -29,7 +29,7 @@ module Liquid
case input
when Integer
input
when NilClass, String
when NilClass, String, Float
input.to_i
else
Utils.to_integer(input)

View File

@@ -29,6 +29,7 @@ class ExpressionTest < Minitest::Test
def test_range
assert_equal(1..2, parse_and_eval("(1..2)"))
assert_equal(3..4, parse_and_eval(" ( 3 .. 4 ) "))
assert_equal(1..2, parse_and_eval("(1.1..2.2)"))
end
private

View File

@@ -50,6 +50,7 @@ HERE
def test_for_with_variable_range
assert_template_result(' 1 2 3 ', '{%for item in (1..foobar) %} {{item}} {%endfor%}', "foobar" => 3)
assert_template_result(' 1 2 3 ', '{%for item in (x..y) %} {{item}} {%endfor%}', "x" => 1.1, "y" => 3.3)
end
def test_for_with_hash_value_range