Fix conditions using negative number comparisons

This commit is contained in:
Dennis Theisen
2012-03-12 16:38:34 -04:00
parent b8d7b9aeda
commit 0e3b522fe2
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -136,11 +136,11 @@ module Liquid
$1
when /^"(.*)"$/ # Double quoted strings
$1
when /^(\d+)$/ # Integer and floats
when /^(-?\d+)$/ # Integer and floats
$1.to_i
when /^\((\S+)\.\.(\S+)\)$/ # Ranges
(resolve($1).to_i..resolve($2).to_i)
when /^(\d[\d\.]+)$/ # Floats
when /^(-?\d[\d\.]+)$/ # Floats
$1.to_f
else
variable(key)
+5
View File
@@ -18,6 +18,11 @@ class ConditionTest < Test::Unit::TestCase
assert_evalutes_true '2', '>=', '1'
assert_evalutes_true '1', '<=', '2'
assert_evalutes_true '1', '<=', '1'
# negative numbers
assert_evalutes_true '1', '>', '-1'
assert_evalutes_true '-1', '<', '1'
assert_evalutes_true '1.0', '>', '-1.0'
assert_evalutes_true '-1.0', '<', '1.0'
end
def test_default_operators_evalute_false