From 2d9331a2348c232edf77ec0cc29b677f522aa2b0 Mon Sep 17 00:00:00 2001 From: DBA Date: Sun, 22 Aug 2010 19:59:53 +0800 Subject: [PATCH] StandardFilters - Ruby 1.9.2-rc changed the float precision, thus the tests are now more generic and backwards compatible. --- test/standard_filter_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/standard_filter_test.rb b/test/standard_filter_test.rb index e316982..30812bd 100644 --- a/test/standard_filter_test.rb +++ b/test/standard_filter_test.rb @@ -147,14 +147,20 @@ class StandardFiltersTest < Test::Unit::TestCase def test_times assert_template_result "12", "{{ 3 | times:4 }}" assert_template_result "0", "{{ 'foo' | times:4 }}" - assert_template_result "6.3", "{{ '2.1' | times:3 }}" + + # Ruby v1.9.2-rc1, or higher, backwards compatible Float test + assert_match(/(6\.3)|(6\.(0{13})1)/, Template.parse("{{ '2.1' | times:3 }}").render) + assert_template_result "6", "{{ '2.1' | times:3 | replace: '.','-' | plus:0}}" end def test_divided_by assert_template_result "4", "{{ 12 | divided_by:3 }}" assert_template_result "4", "{{ 14 | divided_by:3 }}" - assert_template_result "4.66666666666667", "{{ 14 | divided_by:'3.0' }}" + + # Ruby v1.9.2-rc1, or higher, backwards compatible Float test + assert_match(/4\.(6{13,14})7/, Template.parse("{{ 14 | divided_by:'3.0' }}").render) + assert_template_result "5", "{{ 15 | divided_by:3 }}" assert_template_result "Liquid error: divided by 0", "{{ 5 | divided_by:0 }}" end