liquid 3.0.6 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/History.md +243 -58
 - data/README.md +43 -4
 - data/lib/liquid/block.rb +57 -123
 - data/lib/liquid/block_body.rb +217 -85
 - data/lib/liquid/condition.rb +92 -45
 - data/lib/liquid/context.rb +154 -89
 - data/lib/liquid/document.rb +57 -9
 - data/lib/liquid/drop.rb +20 -17
 - data/lib/liquid/errors.rb +27 -29
 - data/lib/liquid/expression.rb +32 -20
 - data/lib/liquid/extensions.rb +21 -7
 - data/lib/liquid/file_system.rb +17 -15
 - data/lib/liquid/forloop_drop.rb +92 -0
 - data/lib/liquid/i18n.rb +10 -8
 - data/lib/liquid/interrupts.rb +4 -3
 - data/lib/liquid/lexer.rb +37 -26
 - data/lib/liquid/locales/en.yml +13 -6
 - data/lib/liquid/parse_context.rb +54 -0
 - data/lib/liquid/parse_tree_visitor.rb +42 -0
 - data/lib/liquid/parser.rb +30 -18
 - data/lib/liquid/parser_switching.rb +20 -6
 - data/lib/liquid/partial_cache.rb +24 -0
 - data/lib/liquid/profiler/hooks.rb +26 -14
 - data/lib/liquid/profiler.rb +72 -92
 - data/lib/liquid/range_lookup.rb +28 -3
 - data/lib/liquid/registers.rb +51 -0
 - data/lib/liquid/resource_limits.rb +62 -0
 - data/lib/liquid/standardfilters.rb +715 -132
 - data/lib/liquid/strainer_factory.rb +41 -0
 - data/lib/liquid/strainer_template.rb +62 -0
 - data/lib/liquid/tablerowloop_drop.rb +121 -0
 - data/lib/liquid/tag/disableable.rb +22 -0
 - data/lib/liquid/tag/disabler.rb +21 -0
 - data/lib/liquid/tag.rb +35 -12
 - data/lib/liquid/tags/assign.rb +57 -18
 - data/lib/liquid/tags/break.rb +15 -5
 - data/lib/liquid/tags/capture.rb +24 -18
 - data/lib/liquid/tags/case.rb +79 -30
 - data/lib/liquid/tags/comment.rb +19 -4
 - data/lib/liquid/tags/continue.rb +16 -12
 - data/lib/liquid/tags/cycle.rb +47 -27
 - data/lib/liquid/tags/decrement.rb +23 -24
 - data/lib/liquid/tags/echo.rb +41 -0
 - data/lib/liquid/tags/for.rb +155 -124
 - data/lib/liquid/tags/if.rb +97 -63
 - data/lib/liquid/tags/ifchanged.rb +11 -12
 - data/lib/liquid/tags/include.rb +82 -73
 - data/lib/liquid/tags/increment.rb +23 -17
 - data/lib/liquid/tags/inline_comment.rb +43 -0
 - data/lib/liquid/tags/raw.rb +50 -8
 - data/lib/liquid/tags/render.rb +109 -0
 - data/lib/liquid/tags/table_row.rb +57 -41
 - data/lib/liquid/tags/unless.rb +38 -20
 - data/lib/liquid/template.rb +71 -103
 - data/lib/liquid/template_factory.rb +9 -0
 - data/lib/liquid/tokenizer.rb +39 -0
 - data/lib/liquid/usage.rb +8 -0
 - data/lib/liquid/utils.rb +63 -9
 - data/lib/liquid/variable.rb +74 -56
 - data/lib/liquid/variable_lookup.rb +31 -15
 - data/lib/liquid/version.rb +3 -1
 - data/lib/liquid.rb +27 -12
 - metadata +30 -106
 - data/lib/liquid/module_ex.rb +0 -62
 - data/lib/liquid/strainer.rb +0 -59
 - data/lib/liquid/token.rb +0 -18
 - data/test/fixtures/en_locale.yml +0 -9
 - data/test/integration/assign_test.rb +0 -48
 - data/test/integration/blank_test.rb +0 -106
 - data/test/integration/capture_test.rb +0 -50
 - data/test/integration/context_test.rb +0 -32
 - data/test/integration/drop_test.rb +0 -271
 - data/test/integration/error_handling_test.rb +0 -207
 - data/test/integration/filter_test.rb +0 -138
 - data/test/integration/hash_ordering_test.rb +0 -23
 - data/test/integration/output_test.rb +0 -124
 - data/test/integration/parsing_quirks_test.rb +0 -116
 - data/test/integration/render_profiling_test.rb +0 -154
 - data/test/integration/security_test.rb +0 -64
 - data/test/integration/standard_filter_test.rb +0 -396
 - data/test/integration/tags/break_tag_test.rb +0 -16
 - data/test/integration/tags/continue_tag_test.rb +0 -16
 - data/test/integration/tags/for_tag_test.rb +0 -375
 - data/test/integration/tags/if_else_tag_test.rb +0 -190
 - data/test/integration/tags/include_tag_test.rb +0 -234
 - data/test/integration/tags/increment_tag_test.rb +0 -24
 - data/test/integration/tags/raw_tag_test.rb +0 -25
 - data/test/integration/tags/standard_tag_test.rb +0 -297
 - data/test/integration/tags/statements_test.rb +0 -113
 - data/test/integration/tags/table_row_test.rb +0 -63
 - data/test/integration/tags/unless_else_tag_test.rb +0 -26
 - data/test/integration/template_test.rb +0 -182
 - data/test/integration/variable_test.rb +0 -82
 - data/test/test_helper.rb +0 -89
 - data/test/unit/block_unit_test.rb +0 -55
 - data/test/unit/condition_unit_test.rb +0 -149
 - data/test/unit/context_unit_test.rb +0 -492
 - data/test/unit/file_system_unit_test.rb +0 -35
 - data/test/unit/i18n_unit_test.rb +0 -37
 - data/test/unit/lexer_unit_test.rb +0 -48
 - data/test/unit/module_ex_unit_test.rb +0 -87
 - data/test/unit/parser_unit_test.rb +0 -82
 - data/test/unit/regexp_unit_test.rb +0 -44
 - data/test/unit/strainer_unit_test.rb +0 -69
 - data/test/unit/tag_unit_test.rb +0 -16
 - data/test/unit/tags/case_tag_unit_test.rb +0 -10
 - data/test/unit/tags/for_tag_unit_test.rb +0 -13
 - data/test/unit/tags/if_tag_unit_test.rb +0 -8
 - data/test/unit/template_unit_test.rb +0 -69
 - data/test/unit/tokenizer_unit_test.rb +0 -38
 - data/test/unit/variable_unit_test.rb +0 -145
 - /data/{MIT-LICENSE → LICENSE} +0 -0
 
    
        data/test/unit/i18n_unit_test.rb
    DELETED
    
    | 
         @@ -1,37 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class I18nUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def setup
         
     | 
| 
       7 
     | 
    
         
            -
                @i18n = I18n.new(fixture("en_locale.yml"))
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              def test_simple_translate_string
         
     | 
| 
       11 
     | 
    
         
            -
                assert_equal "less is more", @i18n.translate("simple")
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              def test_nested_translate_string
         
     | 
| 
       15 
     | 
    
         
            -
                assert_equal "something wasn't right", @i18n.translate("errors.syntax.oops")
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              def test_single_string_interpolation
         
     | 
| 
       19 
     | 
    
         
            -
                assert_equal "something different", @i18n.translate("whatever", :something => "different")
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
              # def test_raises_translation_error_on_undefined_interpolation_key
         
     | 
| 
       23 
     | 
    
         
            -
              #   assert_raises I18n::TranslationError do
         
     | 
| 
       24 
     | 
    
         
            -
              #     @i18n.translate("whatever", :oopstypos => "yes")
         
     | 
| 
       25 
     | 
    
         
            -
              #   end
         
     | 
| 
       26 
     | 
    
         
            -
              # end
         
     | 
| 
       27 
     | 
    
         
            -
              
         
     | 
| 
       28 
     | 
    
         
            -
              def test_raises_unknown_translation
         
     | 
| 
       29 
     | 
    
         
            -
                assert_raises I18n::TranslationError do
         
     | 
| 
       30 
     | 
    
         
            -
                  @i18n.translate("doesnt_exist")
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              def test_sets_default_path_to_en
         
     | 
| 
       35 
     | 
    
         
            -
                assert_equal I18n::DEFAULT_LOCALE, I18n.new.path
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,48 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class LexerUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_strings
         
     | 
| 
       7 
     | 
    
         
            -
                tokens = Lexer.new(%! 'this is a test""' "wat 'lol'"!).tokenize
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal [[:string,%!'this is a test""'!], [:string, %!"wat 'lol'"!], [:end_of_string]], tokens
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def test_integer
         
     | 
| 
       12 
     | 
    
         
            -
                tokens = Lexer.new('hi 50').tokenize
         
     | 
| 
       13 
     | 
    
         
            -
                assert_equal [[:id,'hi'], [:number, '50'], [:end_of_string]], tokens
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              def test_float
         
     | 
| 
       17 
     | 
    
         
            -
                tokens = Lexer.new('hi 5.0').tokenize
         
     | 
| 
       18 
     | 
    
         
            -
                assert_equal [[:id,'hi'], [:number, '5.0'], [:end_of_string]], tokens
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              def test_comparison
         
     | 
| 
       22 
     | 
    
         
            -
                tokens = Lexer.new('== <> contains').tokenize
         
     | 
| 
       23 
     | 
    
         
            -
                assert_equal [[:comparison,'=='], [:comparison, '<>'], [:comparison, 'contains'], [:end_of_string]], tokens
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              def test_specials
         
     | 
| 
       27 
     | 
    
         
            -
                tokens = Lexer.new('| .:').tokenize
         
     | 
| 
       28 
     | 
    
         
            -
                assert_equal [[:pipe, '|'], [:dot, '.'], [:colon, ':'], [:end_of_string]], tokens
         
     | 
| 
       29 
     | 
    
         
            -
                tokens = Lexer.new('[,]').tokenize
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal [[:open_square, '['], [:comma, ','], [:close_square, ']'], [:end_of_string]], tokens
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              def test_fancy_identifiers
         
     | 
| 
       34 
     | 
    
         
            -
                tokens = Lexer.new('hi! five?').tokenize
         
     | 
| 
       35 
     | 
    
         
            -
                assert_equal [[:id,'hi!'], [:id, 'five?'], [:end_of_string]], tokens
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              def test_whitespace
         
     | 
| 
       39 
     | 
    
         
            -
                tokens = Lexer.new("five|\n\t ==").tokenize
         
     | 
| 
       40 
     | 
    
         
            -
                assert_equal [[:id,'five'], [:pipe, '|'], [:comparison, '=='], [:end_of_string]], tokens
         
     | 
| 
       41 
     | 
    
         
            -
              end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
              def test_unexpected_character
         
     | 
| 
       44 
     | 
    
         
            -
                assert_raises(SyntaxError) do
         
     | 
| 
       45 
     | 
    
         
            -
                  Lexer.new("%").tokenize
         
     | 
| 
       46 
     | 
    
         
            -
                end
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,87 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestClassA
         
     | 
| 
       4 
     | 
    
         
            -
              liquid_methods :allowedA, :chainedB
         
     | 
| 
       5 
     | 
    
         
            -
              def allowedA
         
     | 
| 
       6 
     | 
    
         
            -
                'allowedA'
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
              def restrictedA
         
     | 
| 
       9 
     | 
    
         
            -
                'restrictedA'
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
              def chainedB
         
     | 
| 
       12 
     | 
    
         
            -
                TestClassB.new
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            class TestClassB
         
     | 
| 
       17 
     | 
    
         
            -
              liquid_methods :allowedB, :chainedC
         
     | 
| 
       18 
     | 
    
         
            -
              def allowedB
         
     | 
| 
       19 
     | 
    
         
            -
                'allowedB'
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
              def chainedC
         
     | 
| 
       22 
     | 
    
         
            -
                TestClassC.new
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            class TestClassC
         
     | 
| 
       27 
     | 
    
         
            -
              liquid_methods :allowedC
         
     | 
| 
       28 
     | 
    
         
            -
              def allowedC
         
     | 
| 
       29 
     | 
    
         
            -
                'allowedC'
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            class TestClassC::LiquidDropClass
         
     | 
| 
       34 
     | 
    
         
            -
              def another_allowedC
         
     | 
| 
       35 
     | 
    
         
            -
                'another_allowedC'
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
            end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            class ModuleExUnitTest < Minitest::Test
         
     | 
| 
       40 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              def setup
         
     | 
| 
       43 
     | 
    
         
            -
                @a = TestClassA.new
         
     | 
| 
       44 
     | 
    
         
            -
                @b = TestClassB.new
         
     | 
| 
       45 
     | 
    
         
            -
                @c = TestClassC.new
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              def test_should_create_LiquidDropClass
         
     | 
| 
       49 
     | 
    
         
            -
                assert TestClassA::LiquidDropClass
         
     | 
| 
       50 
     | 
    
         
            -
                assert TestClassB::LiquidDropClass
         
     | 
| 
       51 
     | 
    
         
            -
                assert TestClassC::LiquidDropClass
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
              def test_should_respond_to_liquid
         
     | 
| 
       55 
     | 
    
         
            -
                assert @a.respond_to?(:to_liquid)
         
     | 
| 
       56 
     | 
    
         
            -
                assert @b.respond_to?(:to_liquid)
         
     | 
| 
       57 
     | 
    
         
            -
                assert @c.respond_to?(:to_liquid)
         
     | 
| 
       58 
     | 
    
         
            -
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              def test_should_return_LiquidDropClass_object
         
     | 
| 
       61 
     | 
    
         
            -
                assert @a.to_liquid.is_a?(TestClassA::LiquidDropClass)
         
     | 
| 
       62 
     | 
    
         
            -
                assert @b.to_liquid.is_a?(TestClassB::LiquidDropClass)
         
     | 
| 
       63 
     | 
    
         
            -
                assert @c.to_liquid.is_a?(TestClassC::LiquidDropClass)
         
     | 
| 
       64 
     | 
    
         
            -
              end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
              def test_should_respond_to_liquid_methods
         
     | 
| 
       67 
     | 
    
         
            -
                assert @a.to_liquid.respond_to?(:allowedA)
         
     | 
| 
       68 
     | 
    
         
            -
                assert @a.to_liquid.respond_to?(:chainedB)
         
     | 
| 
       69 
     | 
    
         
            -
                assert @b.to_liquid.respond_to?(:allowedB)
         
     | 
| 
       70 
     | 
    
         
            -
                assert @b.to_liquid.respond_to?(:chainedC)
         
     | 
| 
       71 
     | 
    
         
            -
                assert @c.to_liquid.respond_to?(:allowedC)
         
     | 
| 
       72 
     | 
    
         
            -
                assert @c.to_liquid.respond_to?(:another_allowedC)
         
     | 
| 
       73 
     | 
    
         
            -
              end
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
              def test_should_not_respond_to_restricted_methods
         
     | 
| 
       76 
     | 
    
         
            -
                assert ! @a.to_liquid.respond_to?(:restricted)
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
              def test_should_use_regular_objects_as_drops
         
     | 
| 
       80 
     | 
    
         
            -
                assert_template_result 'allowedA', "{{ a.allowedA }}", 'a'=>@a
         
     | 
| 
       81 
     | 
    
         
            -
                assert_template_result 'allowedB', "{{ a.chainedB.allowedB }}", 'a'=>@a
         
     | 
| 
       82 
     | 
    
         
            -
                assert_template_result 'allowedC', "{{ a.chainedB.chainedC.allowedC }}", 'a'=>@a
         
     | 
| 
       83 
     | 
    
         
            -
                assert_template_result 'another_allowedC', "{{ a.chainedB.chainedC.another_allowedC }}", 'a'=>@a
         
     | 
| 
       84 
     | 
    
         
            -
                assert_template_result '', "{{ a.restricted }}", 'a'=>@a
         
     | 
| 
       85 
     | 
    
         
            -
                assert_template_result '', "{{ a.unknown }}", 'a'=>@a
         
     | 
| 
       86 
     | 
    
         
            -
              end
         
     | 
| 
       87 
     | 
    
         
            -
            end # ModuleExTest
         
     | 
| 
         @@ -1,82 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class ParserUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_consume
         
     | 
| 
       7 
     | 
    
         
            -
                p = Parser.new("wat: 7")
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal 'wat', p.consume(:id)
         
     | 
| 
       9 
     | 
    
         
            -
                assert_equal ':', p.consume(:colon)
         
     | 
| 
       10 
     | 
    
         
            -
                assert_equal '7', p.consume(:number)
         
     | 
| 
       11 
     | 
    
         
            -
              end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              def test_jump
         
     | 
| 
       14 
     | 
    
         
            -
                p = Parser.new("wat: 7")
         
     | 
| 
       15 
     | 
    
         
            -
                p.jump(2)
         
     | 
| 
       16 
     | 
    
         
            -
                assert_equal '7', p.consume(:number)
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              def test_consume?
         
     | 
| 
       20 
     | 
    
         
            -
                p = Parser.new("wat: 7")
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal 'wat', p.consume?(:id)
         
     | 
| 
       22 
     | 
    
         
            -
                assert_equal false, p.consume?(:dot)
         
     | 
| 
       23 
     | 
    
         
            -
                assert_equal ':', p.consume(:colon)
         
     | 
| 
       24 
     | 
    
         
            -
                assert_equal '7', p.consume?(:number)
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              def test_id?
         
     | 
| 
       28 
     | 
    
         
            -
                p = Parser.new("wat 6 Peter Hegemon")
         
     | 
| 
       29 
     | 
    
         
            -
                assert_equal 'wat', p.id?('wat')
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal false, p.id?('endgame')
         
     | 
| 
       31 
     | 
    
         
            -
                assert_equal '6', p.consume(:number)
         
     | 
| 
       32 
     | 
    
         
            -
                assert_equal 'Peter', p.id?('Peter')
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal false, p.id?('Achilles')
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              def test_look
         
     | 
| 
       37 
     | 
    
         
            -
                p = Parser.new("wat 6 Peter Hegemon")
         
     | 
| 
       38 
     | 
    
         
            -
                assert_equal true, p.look(:id)
         
     | 
| 
       39 
     | 
    
         
            -
                assert_equal 'wat', p.consume(:id)
         
     | 
| 
       40 
     | 
    
         
            -
                assert_equal false, p.look(:comparison)
         
     | 
| 
       41 
     | 
    
         
            -
                assert_equal true, p.look(:number)
         
     | 
| 
       42 
     | 
    
         
            -
                assert_equal true, p.look(:id, 1)
         
     | 
| 
       43 
     | 
    
         
            -
                assert_equal false, p.look(:number, 1)
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              def test_expressions
         
     | 
| 
       47 
     | 
    
         
            -
                p = Parser.new("hi.there hi[5].! hi.there.bob")
         
     | 
| 
       48 
     | 
    
         
            -
                assert_equal 'hi.there', p.expression
         
     | 
| 
       49 
     | 
    
         
            -
                assert_equal 'hi[5].!', p.expression
         
     | 
| 
       50 
     | 
    
         
            -
                assert_equal 'hi.there.bob', p.expression
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                p = Parser.new("567 6.0 'lol' \"wut\"")
         
     | 
| 
       53 
     | 
    
         
            -
                assert_equal '567', p.expression
         
     | 
| 
       54 
     | 
    
         
            -
                assert_equal '6.0', p.expression
         
     | 
| 
       55 
     | 
    
         
            -
                assert_equal "'lol'", p.expression
         
     | 
| 
       56 
     | 
    
         
            -
                assert_equal '"wut"', p.expression
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_ranges
         
     | 
| 
       60 
     | 
    
         
            -
                p = Parser.new("(5..7) (1.5..9.6) (young..old) (hi[5].wat..old)")
         
     | 
| 
       61 
     | 
    
         
            -
                assert_equal '(5..7)', p.expression
         
     | 
| 
       62 
     | 
    
         
            -
                assert_equal '(1.5..9.6)', p.expression
         
     | 
| 
       63 
     | 
    
         
            -
                assert_equal '(young..old)', p.expression
         
     | 
| 
       64 
     | 
    
         
            -
                assert_equal '(hi[5].wat..old)', p.expression
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
              def test_arguments
         
     | 
| 
       68 
     | 
    
         
            -
                p = Parser.new("filter: hi.there[5], keyarg: 7")
         
     | 
| 
       69 
     | 
    
         
            -
                assert_equal 'filter', p.consume(:id)
         
     | 
| 
       70 
     | 
    
         
            -
                assert_equal ':', p.consume(:colon)
         
     | 
| 
       71 
     | 
    
         
            -
                assert_equal 'hi.there[5]', p.argument
         
     | 
| 
       72 
     | 
    
         
            -
                assert_equal ',', p.consume(:comma)
         
     | 
| 
       73 
     | 
    
         
            -
                assert_equal 'keyarg: 7', p.argument
         
     | 
| 
       74 
     | 
    
         
            -
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
              def test_invalid_expression
         
     | 
| 
       77 
     | 
    
         
            -
                assert_raises(SyntaxError) do
         
     | 
| 
       78 
     | 
    
         
            -
                  p = Parser.new("==")
         
     | 
| 
       79 
     | 
    
         
            -
                  p.expression
         
     | 
| 
       80 
     | 
    
         
            -
                end
         
     | 
| 
       81 
     | 
    
         
            -
              end
         
     | 
| 
       82 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,44 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class RegexpUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_empty
         
     | 
| 
       7 
     | 
    
         
            -
                assert_equal [], ''.scan(QuotedFragment)
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              def test_quote
         
     | 
| 
       11 
     | 
    
         
            -
                assert_equal ['"arg 1"'], '"arg 1"'.scan(QuotedFragment)
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              def test_words
         
     | 
| 
       15 
     | 
    
         
            -
                assert_equal ['arg1', 'arg2'], 'arg1 arg2'.scan(QuotedFragment)
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              def test_tags
         
     | 
| 
       19 
     | 
    
         
            -
                assert_equal ['<tr>', '</tr>'], '<tr> </tr>'.scan(QuotedFragment)
         
     | 
| 
       20 
     | 
    
         
            -
                assert_equal ['<tr></tr>'], '<tr></tr>'.scan(QuotedFragment)
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal ['<style', 'class="hello">', '</style>'], %|<style class="hello">' </style>|.scan(QuotedFragment)
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              def test_double_quoted_words
         
     | 
| 
       25 
     | 
    
         
            -
                assert_equal ['arg1', 'arg2', '"arg 3"'], 'arg1 arg2 "arg 3"'.scan(QuotedFragment)
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              def test_single_quoted_words
         
     | 
| 
       29 
     | 
    
         
            -
                assert_equal ['arg1', 'arg2', "'arg 3'"], 'arg1 arg2 \'arg 3\''.scan(QuotedFragment)
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              def test_quoted_words_in_the_middle
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal ['arg1', 'arg2', '"arg 3"', 'arg4'], 'arg1 arg2 "arg 3" arg4   '.scan(QuotedFragment)
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              def test_variable_parser
         
     | 
| 
       37 
     | 
    
         
            -
                assert_equal ['var'],                               'var'.scan(VariableParser)
         
     | 
| 
       38 
     | 
    
         
            -
                assert_equal ['var', 'method'],                     'var.method'.scan(VariableParser)
         
     | 
| 
       39 
     | 
    
         
            -
                assert_equal ['var', '[method]'],                   'var[method]'.scan(VariableParser)
         
     | 
| 
       40 
     | 
    
         
            -
                assert_equal ['var', '[method]', '[0]'],            'var[method][0]'.scan(VariableParser)
         
     | 
| 
       41 
     | 
    
         
            -
                assert_equal ['var', '["method"]', '[0]'],          'var["method"][0]'.scan(VariableParser)
         
     | 
| 
       42 
     | 
    
         
            -
                assert_equal ['var', '[method]', '[0]', 'method'],  'var[method][0].method'.scan(VariableParser)
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
            end # RegexpTest
         
     | 
| 
         @@ -1,69 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class StrainerUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              module AccessScopeFilters
         
     | 
| 
       7 
     | 
    
         
            -
                def public_filter
         
     | 
| 
       8 
     | 
    
         
            -
                  "public"
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def private_filter
         
     | 
| 
       12 
     | 
    
         
            -
                  "private"
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
                private :private_filter
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              Strainer.global_filter(AccessScopeFilters)
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              def test_strainer
         
     | 
| 
       20 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal 5, strainer.invoke('size', 'input')
         
     | 
| 
       22 
     | 
    
         
            -
                assert_equal "public", strainer.invoke("public_filter")
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
              def test_stainer_raises_argument_error
         
     | 
| 
       26 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       27 
     | 
    
         
            -
                assert_raises(Liquid::ArgumentError) do
         
     | 
| 
       28 
     | 
    
         
            -
                  strainer.invoke("public_filter", 1)
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              def test_strainer_only_invokes_public_filter_methods
         
     | 
| 
       33 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       34 
     | 
    
         
            -
                assert_equal false, strainer.class.invokable?('__test__')
         
     | 
| 
       35 
     | 
    
         
            -
                assert_equal false, strainer.class.invokable?('test')
         
     | 
| 
       36 
     | 
    
         
            -
                assert_equal false, strainer.class.invokable?('instance_eval')
         
     | 
| 
       37 
     | 
    
         
            -
                assert_equal false, strainer.class.invokable?('__send__')
         
     | 
| 
       38 
     | 
    
         
            -
                assert_equal true, strainer.class.invokable?('size') # from the standard lib
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              def test_strainer_returns_nil_if_no_filter_method_found
         
     | 
| 
       42 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       43 
     | 
    
         
            -
                assert_nil strainer.invoke("private_filter")
         
     | 
| 
       44 
     | 
    
         
            -
                assert_nil strainer.invoke("undef_the_filter")
         
     | 
| 
       45 
     | 
    
         
            -
              end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
              def test_strainer_returns_first_argument_if_no_method_and_arguments_given
         
     | 
| 
       48 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       49 
     | 
    
         
            -
                assert_equal "password", strainer.invoke("undef_the_method", "password")
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
              def test_strainer_only_allows_methods_defined_in_filters
         
     | 
| 
       53 
     | 
    
         
            -
                strainer = Strainer.create(nil)
         
     | 
| 
       54 
     | 
    
         
            -
                assert_equal "1 + 1", strainer.invoke("instance_eval", "1 + 1")
         
     | 
| 
       55 
     | 
    
         
            -
                assert_equal "puts",  strainer.invoke("__send__", "puts", "Hi Mom")
         
     | 
| 
       56 
     | 
    
         
            -
                assert_equal "has_method?", strainer.invoke("invoke", "has_method?", "invoke")
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation
         
     | 
| 
       60 
     | 
    
         
            -
                a = Module.new
         
     | 
| 
       61 
     | 
    
         
            -
                b = Module.new
         
     | 
| 
       62 
     | 
    
         
            -
                strainer = Strainer.create(nil, [a,b])
         
     | 
| 
       63 
     | 
    
         
            -
                assert_kind_of Strainer, strainer
         
     | 
| 
       64 
     | 
    
         
            -
                assert_kind_of a, strainer
         
     | 
| 
       65 
     | 
    
         
            -
                assert_kind_of b, strainer
         
     | 
| 
       66 
     | 
    
         
            -
                assert_kind_of Liquid::StandardFilters, strainer
         
     | 
| 
       67 
     | 
    
         
            -
              end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
            end # StrainerTest
         
     | 
    
        data/test/unit/tag_unit_test.rb
    DELETED
    
    | 
         @@ -1,16 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TagUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_tag
         
     | 
| 
       7 
     | 
    
         
            -
                tag = Tag.parse('tag', [], [], {})
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal 'liquid::tag', tag.name
         
     | 
| 
       9 
     | 
    
         
            -
                assert_equal '', tag.render(Context.new)
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              def test_return_raw_text_of_tag
         
     | 
| 
       13 
     | 
    
         
            -
                tag = Tag.parse("long_tag", "param1, param2, param3", [], {})
         
     | 
| 
       14 
     | 
    
         
            -
                assert_equal("long_tag param1, param2, param3", tag.raw)
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,10 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class CaseTagUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_case_nodelist
         
     | 
| 
       7 
     | 
    
         
            -
                template = Liquid::Template.parse('{% case var %}{% when true %}WHEN{% else %}ELSE{% endcase %}')
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal ['WHEN', 'ELSE'], template.root.nodelist[0].nodelist
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class ForTagUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              def test_for_nodelist
         
     | 
| 
       5 
     | 
    
         
            -
                template = Liquid::Template.parse('{% for item in items %}FOR{% endfor %}')
         
     | 
| 
       6 
     | 
    
         
            -
                assert_equal ['FOR'], template.root.nodelist[0].nodelist
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_for_else_nodelist
         
     | 
| 
       10 
     | 
    
         
            -
                template = Liquid::Template.parse('{% for item in items %}FOR{% else %}ELSE{% endfor %}')
         
     | 
| 
       11 
     | 
    
         
            -
                assert_equal ['FOR', 'ELSE'], template.root.nodelist[0].nodelist
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,69 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TemplateUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_sets_default_localization_in_document
         
     | 
| 
       7 
     | 
    
         
            -
                t = Template.new
         
     | 
| 
       8 
     | 
    
         
            -
                t.parse('')
         
     | 
| 
       9 
     | 
    
         
            -
                assert_instance_of I18n, t.root.options[:locale]
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              def test_sets_default_localization_in_context_with_quick_initialization
         
     | 
| 
       13 
     | 
    
         
            -
                t = Template.new
         
     | 
| 
       14 
     | 
    
         
            -
                t.parse('{{foo}}', :locale => I18n.new(fixture("en_locale.yml")))
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                assert_instance_of I18n, t.root.options[:locale]
         
     | 
| 
       17 
     | 
    
         
            -
                assert_equal fixture("en_locale.yml"), t.root.options[:locale].path
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              def test_with_cache_classes_tags_returns_the_same_class
         
     | 
| 
       21 
     | 
    
         
            -
                original_cache_setting = Liquid.cache_classes
         
     | 
| 
       22 
     | 
    
         
            -
                Liquid.cache_classes = true
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                original_klass = Class.new
         
     | 
| 
       25 
     | 
    
         
            -
                Object.send(:const_set, :CustomTag, original_klass)
         
     | 
| 
       26 
     | 
    
         
            -
                Template.register_tag('custom', CustomTag)
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                Object.send(:remove_const, :CustomTag)
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                new_klass = Class.new
         
     | 
| 
       31 
     | 
    
         
            -
                Object.send(:const_set, :CustomTag, new_klass)
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                assert Template.tags['custom'].equal?(original_klass)
         
     | 
| 
       34 
     | 
    
         
            -
              ensure
         
     | 
| 
       35 
     | 
    
         
            -
                Object.send(:remove_const, :CustomTag)
         
     | 
| 
       36 
     | 
    
         
            -
                Template.tags.delete('custom')
         
     | 
| 
       37 
     | 
    
         
            -
                Liquid.cache_classes = original_cache_setting
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              def test_without_cache_classes_tags_reloads_the_class
         
     | 
| 
       41 
     | 
    
         
            -
                original_cache_setting = Liquid.cache_classes
         
     | 
| 
       42 
     | 
    
         
            -
                Liquid.cache_classes = false
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                original_klass = Class.new
         
     | 
| 
       45 
     | 
    
         
            -
                Object.send(:const_set, :CustomTag, original_klass)
         
     | 
| 
       46 
     | 
    
         
            -
                Template.register_tag('custom', CustomTag)
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                Object.send(:remove_const, :CustomTag)
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                new_klass = Class.new
         
     | 
| 
       51 
     | 
    
         
            -
                Object.send(:const_set, :CustomTag, new_klass)
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                assert Template.tags['custom'].equal?(new_klass)
         
     | 
| 
       54 
     | 
    
         
            -
              ensure
         
     | 
| 
       55 
     | 
    
         
            -
                Object.send(:remove_const, :CustomTag)
         
     | 
| 
       56 
     | 
    
         
            -
                Template.tags.delete('custom')
         
     | 
| 
       57 
     | 
    
         
            -
                Liquid.cache_classes = original_cache_setting
         
     | 
| 
       58 
     | 
    
         
            -
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              class FakeTag; end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
              def test_tags_delete
         
     | 
| 
       63 
     | 
    
         
            -
                Template.register_tag('fake', FakeTag)
         
     | 
| 
       64 
     | 
    
         
            -
                assert_equal FakeTag, Template.tags['fake']
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                Template.tags.delete('fake')
         
     | 
| 
       67 
     | 
    
         
            -
                assert_nil Template.tags['fake']
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,38 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TokenizerTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              def test_tokenize_strings
         
     | 
| 
       5 
     | 
    
         
            -
                assert_equal [' '], tokenize(' ')
         
     | 
| 
       6 
     | 
    
         
            -
                assert_equal ['hello world'], tokenize('hello world')
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_tokenize_variables
         
     | 
| 
       10 
     | 
    
         
            -
                assert_equal ['{{funk}}'], tokenize('{{funk}}')
         
     | 
| 
       11 
     | 
    
         
            -
                assert_equal [' ', '{{funk}}', ' '], tokenize(' {{funk}} ')
         
     | 
| 
       12 
     | 
    
         
            -
                assert_equal [' ', '{{funk}}', ' ', '{{so}}', ' ', '{{brother}}', ' '], tokenize(' {{funk}} {{so}} {{brother}} ')
         
     | 
| 
       13 
     | 
    
         
            -
                assert_equal [' ', '{{  funk  }}', ' '], tokenize(' {{  funk  }} ')
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              def test_tokenize_blocks
         
     | 
| 
       17 
     | 
    
         
            -
                assert_equal ['{%comment%}'], tokenize('{%comment%}')
         
     | 
| 
       18 
     | 
    
         
            -
                assert_equal [' ', '{%comment%}', ' '], tokenize(' {%comment%} ')
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                assert_equal [' ', '{%comment%}', ' ', '{%endcomment%}', ' '], tokenize(' {%comment%} {%endcomment%} ')
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal ['  ', '{% comment %}', ' ', '{% endcomment %}', ' '], tokenize("  {% comment %} {% endcomment %} ")
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              def test_calculate_line_numbers_per_token_with_profiling
         
     | 
| 
       25 
     | 
    
         
            -
                template = Liquid::Template.parse("", :profile => true)
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                assert_equal [1],       template.send(:tokenize, "{{funk}}").map(&:line_number)
         
     | 
| 
       28 
     | 
    
         
            -
                assert_equal [1, 1, 1], template.send(:tokenize, " {{funk}} ").map(&:line_number)
         
     | 
| 
       29 
     | 
    
         
            -
                assert_equal [1, 2, 2], template.send(:tokenize, "\n{{funk}}\n").map(&:line_number)
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal [1, 1, 3], template.send(:tokenize, " {{\n funk \n}} ").map(&:line_number)
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              private
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
              def tokenize(source)
         
     | 
| 
       36 
     | 
    
         
            -
                Liquid::Template.new.send(:tokenize, source)
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,145 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'test_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class VariableUnitTest < Minitest::Test
         
     | 
| 
       4 
     | 
    
         
            -
              include Liquid
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              def test_variable
         
     | 
| 
       7 
     | 
    
         
            -
                var = Variable.new('hello')
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def test_filters
         
     | 
| 
       12 
     | 
    
         
            -
                var = Variable.new('hello | textileze')
         
     | 
| 
       13 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       14 
     | 
    
         
            -
                assert_equal [['textileze',[]]], var.filters
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                var = Variable.new('hello | textileze | paragraph')
         
     | 
| 
       17 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       18 
     | 
    
         
            -
                assert_equal [['textileze',[]], ['paragraph',[]]], var.filters
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                var = Variable.new(%! hello | strftime: '%Y'!)
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       22 
     | 
    
         
            -
                assert_equal [['strftime',['%Y']]], var.filters
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                var = Variable.new(%! 'typo' | link_to: 'Typo', true !)
         
     | 
| 
       25 
     | 
    
         
            -
                assert_equal 'typo', var.name
         
     | 
| 
       26 
     | 
    
         
            -
                assert_equal [['link_to',['Typo', true]]], var.filters
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                var = Variable.new(%! 'typo' | link_to: 'Typo', false !)
         
     | 
| 
       29 
     | 
    
         
            -
                assert_equal 'typo', var.name
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal [['link_to',['Typo', false]]], var.filters
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                var = Variable.new(%! 'foo' | repeat: 3 !)
         
     | 
| 
       33 
     | 
    
         
            -
                assert_equal 'foo', var.name
         
     | 
| 
       34 
     | 
    
         
            -
                assert_equal [['repeat',[3]]], var.filters
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                var = Variable.new(%! 'foo' | repeat: 3, 3 !)
         
     | 
| 
       37 
     | 
    
         
            -
                assert_equal 'foo', var.name
         
     | 
| 
       38 
     | 
    
         
            -
                assert_equal [['repeat',[3,3]]], var.filters
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                var = Variable.new(%! 'foo' | repeat: 3, 3, 3 !)
         
     | 
| 
       41 
     | 
    
         
            -
                assert_equal 'foo', var.name
         
     | 
| 
       42 
     | 
    
         
            -
                assert_equal [['repeat',[3,3,3]]], var.filters
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                var = Variable.new(%! hello | strftime: '%Y, okay?'!)
         
     | 
| 
       45 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       46 
     | 
    
         
            -
                assert_equal [['strftime',['%Y, okay?']]], var.filters
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                var = Variable.new(%! hello | things: "%Y, okay?", 'the other one'!)
         
     | 
| 
       49 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       50 
     | 
    
         
            -
                assert_equal [['things',['%Y, okay?','the other one']]], var.filters
         
     | 
| 
       51 
     | 
    
         
            -
              end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
              def test_filter_with_date_parameter
         
     | 
| 
       54 
     | 
    
         
            -
                var = Variable.new(%! '2006-06-06' | date: "%m/%d/%Y"!)
         
     | 
| 
       55 
     | 
    
         
            -
                assert_equal '2006-06-06', var.name
         
     | 
| 
       56 
     | 
    
         
            -
                assert_equal [['date',['%m/%d/%Y']]], var.filters
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_filters_without_whitespace
         
     | 
| 
       60 
     | 
    
         
            -
                var = Variable.new('hello | textileze | paragraph')
         
     | 
| 
       61 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       62 
     | 
    
         
            -
                assert_equal [['textileze',[]], ['paragraph',[]]], var.filters
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                var = Variable.new('hello|textileze|paragraph')
         
     | 
| 
       65 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       66 
     | 
    
         
            -
                assert_equal [['textileze',[]], ['paragraph',[]]], var.filters
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                var = Variable.new("hello|replace:'foo','bar'|textileze")
         
     | 
| 
       69 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       70 
     | 
    
         
            -
                assert_equal [['replace', ['foo', 'bar']], ['textileze', []]], var.filters
         
     | 
| 
       71 
     | 
    
         
            -
              end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
              def test_symbol
         
     | 
| 
       74 
     | 
    
         
            -
                var = Variable.new("http://disney.com/logo.gif | image: 'med' ", :error_mode => :lax)
         
     | 
| 
       75 
     | 
    
         
            -
                assert_equal VariableLookup.new('http://disney.com/logo.gif'), var.name
         
     | 
| 
       76 
     | 
    
         
            -
                assert_equal [['image',['med']]], var.filters
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
              def test_string_to_filter
         
     | 
| 
       80 
     | 
    
         
            -
                var = Variable.new("'http://disney.com/logo.gif' | image: 'med' ")
         
     | 
| 
       81 
     | 
    
         
            -
                assert_equal 'http://disney.com/logo.gif', var.name
         
     | 
| 
       82 
     | 
    
         
            -
                assert_equal [['image',['med']]], var.filters
         
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
              def test_string_single_quoted
         
     | 
| 
       86 
     | 
    
         
            -
                var = Variable.new(%| "hello" |)
         
     | 
| 
       87 
     | 
    
         
            -
                assert_equal 'hello', var.name
         
     | 
| 
       88 
     | 
    
         
            -
              end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
              def test_string_double_quoted
         
     | 
| 
       91 
     | 
    
         
            -
                var = Variable.new(%| 'hello' |)
         
     | 
| 
       92 
     | 
    
         
            -
                assert_equal 'hello', var.name
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              def test_integer
         
     | 
| 
       96 
     | 
    
         
            -
                var = Variable.new(%| 1000 |)
         
     | 
| 
       97 
     | 
    
         
            -
                assert_equal 1000, var.name
         
     | 
| 
       98 
     | 
    
         
            -
              end
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
              def test_float
         
     | 
| 
       101 
     | 
    
         
            -
                var = Variable.new(%| 1000.01 |)
         
     | 
| 
       102 
     | 
    
         
            -
                assert_equal 1000.01, var.name
         
     | 
| 
       103 
     | 
    
         
            -
              end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
              def test_string_with_special_chars
         
     | 
| 
       106 
     | 
    
         
            -
                var = Variable.new(%| 'hello! $!@.;"ddasd" ' |)
         
     | 
| 
       107 
     | 
    
         
            -
                assert_equal 'hello! $!@.;"ddasd" ', var.name
         
     | 
| 
       108 
     | 
    
         
            -
              end
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
              def test_string_dot
         
     | 
| 
       111 
     | 
    
         
            -
                var = Variable.new(%| test.test |)
         
     | 
| 
       112 
     | 
    
         
            -
                assert_equal VariableLookup.new('test.test'), var.name
         
     | 
| 
       113 
     | 
    
         
            -
              end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
              def test_filter_with_keyword_arguments
         
     | 
| 
       116 
     | 
    
         
            -
                var = Variable.new(%! hello | things: greeting: "world", farewell: 'goodbye'!)
         
     | 
| 
       117 
     | 
    
         
            -
                assert_equal VariableLookup.new('hello'), var.name
         
     | 
| 
       118 
     | 
    
         
            -
                assert_equal [['things', [], { 'greeting' => 'world', 'farewell' => 'goodbye' }]], var.filters
         
     | 
| 
       119 
     | 
    
         
            -
              end
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
              def test_lax_filter_argument_parsing
         
     | 
| 
       122 
     | 
    
         
            -
                var = Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !, :error_mode => :lax)
         
     | 
| 
       123 
     | 
    
         
            -
                assert_equal VariableLookup.new('number_of_comments'), var.name
         
     | 
| 
       124 
     | 
    
         
            -
                assert_equal [['pluralize',['comment','comments']]], var.filters
         
     | 
| 
       125 
     | 
    
         
            -
              end
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
              def test_strict_filter_argument_parsing
         
     | 
| 
       128 
     | 
    
         
            -
                with_error_mode(:strict) do
         
     | 
| 
       129 
     | 
    
         
            -
                  assert_raises(SyntaxError) do
         
     | 
| 
       130 
     | 
    
         
            -
                    Variable.new(%! number_of_comments | pluralize: 'comment': 'comments' !)
         
     | 
| 
       131 
     | 
    
         
            -
                  end
         
     | 
| 
       132 
     | 
    
         
            -
                end
         
     | 
| 
       133 
     | 
    
         
            -
              end
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
              def test_output_raw_source_of_variable
         
     | 
| 
       136 
     | 
    
         
            -
                var = Variable.new(%! name_of_variable | upcase !)
         
     | 
| 
       137 
     | 
    
         
            -
                assert_equal " name_of_variable | upcase ", var.raw
         
     | 
| 
       138 
     | 
    
         
            -
              end
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
              def test_variable_lookup_interface
         
     | 
| 
       141 
     | 
    
         
            -
                lookup = VariableLookup.new('a.b.c')
         
     | 
| 
       142 
     | 
    
         
            -
                assert_equal 'a', lookup.name
         
     | 
| 
       143 
     | 
    
         
            -
                assert_equal ['b', 'c'], lookup.lookups
         
     | 
| 
       144 
     | 
    
         
            -
              end
         
     | 
| 
       145 
     | 
    
         
            -
            end
         
     | 
    
        /data/{MIT-LICENSE → LICENSE}
    RENAMED
    
    | 
         
            File without changes
         
     |