mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 10:20:43 -07:00
Add support for parenthesized expressions
This commit is contained in:
@@ -35,13 +35,26 @@ class AssignTest < Minitest::Test
|
||||
)
|
||||
end
|
||||
|
||||
def test_assign_boolean_expression_assignment
|
||||
assert_template_result(
|
||||
'it rendered',
|
||||
<<~LIQUID,
|
||||
{%- assign should_render = a == 0 or (b == 1 and c == 2) -%}
|
||||
{%- if should_render -%}
|
||||
it rendered
|
||||
{%- endif -%}
|
||||
LIQUID
|
||||
{ 'b' => 1, 'c' => 2 },
|
||||
)
|
||||
end
|
||||
|
||||
def test_assign_syntax_error
|
||||
assert_match_syntax_error(/assign/, '{% assign foo not values %}.')
|
||||
end
|
||||
|
||||
def test_assign_throws_on_unsupported_syntax
|
||||
assert_match_syntax_error(
|
||||
"Expected dotdot but found pipe",
|
||||
"Expected close_round but found pipe",
|
||||
"{% assign foo = ('X' | downcase) %}",
|
||||
)
|
||||
end
|
||||
|
||||
@@ -35,11 +35,10 @@ class ParsingQuirksTest < Minitest::Test
|
||||
assert_raises(Liquid::SyntaxError) { Template.parse("{{test |a|b|}}") }
|
||||
end
|
||||
|
||||
def test_meaningless_parens_error
|
||||
assert_raises(SyntaxError) do
|
||||
markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false"
|
||||
Template.parse("{% if #{markup} %} YES {% endif %}")
|
||||
end
|
||||
def test_supported_parens
|
||||
markup = "a == 'foo' or (b == 'bar' and c == 'baz') or false"
|
||||
out = Template.parse("{% if #{markup} %} YES {% endif %}").render({ 'b' => 'bar', 'c' => 'baz' })
|
||||
assert_equal(' YES ', out)
|
||||
end
|
||||
|
||||
def test_unexpected_characters_syntax_error
|
||||
|
||||
Reference in New Issue
Block a user