From ab455480facb1c4ad19cb0cbee8b9419cb926591 Mon Sep 17 00:00:00 2001 From: Tobias Lutke Date: Thu, 25 Feb 2021 14:35:31 -0400 Subject: [PATCH] exploring the comment syntax a bit --- test/integration/tags/inline_comment_test.rb | 38 +++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/test/integration/tags/inline_comment_test.rb b/test/integration/tags/inline_comment_test.rb index 55db2273d..f345b74fa 100644 --- a/test/integration/tags/inline_comment_test.rb +++ b/test/integration/tags/inline_comment_test.rb @@ -5,8 +5,35 @@ class InlineCommentTest < Minitest::Test include Liquid - def test_tag + def test_tag_in_different_styles assert_template_result('', '{% # This text gets ignored %}') + assert_template_result('', '{%# This text gets ignored #%}') + assert_template_result('', '{%# This text gets ignored %}') + assert_template_result('', '{%#- This text gets ignored -#%}') + end + + def test_test_syntax_error + assert_template_result('fail', '{% #This doesnt work %}') + + assert false + rescue + # ok good + end + + def test_tag_ws_stripping + assert_template_result('', ' {%#- This text gets ignored -#%} ') + end + + def test_comment_inline_tag + assert_template_result('ok', '{% echo "ok" # output something from a tag %}') + + assert_template_result('ok', '{% # this sort of comment also + echo "ok" %}') + end + + def test_comment_inline_variable + assert_template_result('ok', '{{ "ok" # output something from a variable }}') + assert_template_result('ok', '{{ "OK" | downcase # output something from a variable }}') end def test_inside_liquid_tag @@ -20,8 +47,11 @@ def test_inside_liquid_tag assert_template_result('before()after', source) end - def test_no_space_after_hash_symbol - assert_template_result('', '{% #immediate text %}') - assert_template_result('', '{% liquid #immediate text %}') + def test_multiline + assert_template_result('', '{% # this sort of comment also + # will just work, because it parses + # as a single call to the "#" tag %}') + end + end