@@ -398,14 +398,9 @@ def test_conditions_with_boolean_operators_without_whitespace_around_operator
398
398
HTML
399
399
400
400
# This bugged output only happens in lax mode.
401
- prev_error_mode = Liquid ::Environment . default . error_mode
402
- Liquid ::Environment . default . error_mode = :lax
403
- actual_lax_output = Liquid ::Template . parse ( template ) . render ( context )
404
- Liquid ::Environment . default . error_mode = prev_error_mode
401
+ assert_with_lax_parsing ( template , expected_lax_output , context )
405
402
406
- actual_strict_output = Liquid ::Template . parse ( template ) . render ( context )
407
-
408
- assert_equal ( expected_lax_output . delete ( "\n " ) , actual_lax_output . delete ( "\n " ) )
403
+ # Default test parsing mode (strict) works as properly expected
409
404
assert_equal ( expected_strict_output . delete ( "\n " ) , actual_strict_output . delete ( "\n " ) )
410
405
end
411
406
@@ -471,6 +466,28 @@ def test_chained_conditional_with_object_contains
471
466
assert_with_lax_parsing ( template , "true" , context_without_collection )
472
467
end
473
468
469
+ # TESTING INCORRECT BEHAVIOUR OF LIQUID-RUBY
470
+ # If liquid-vm fails this test, we should change it.
471
+ def test_assign_boolean_expression_to_variable
472
+ template = <<~LIQUID
473
+ {%- liquid
474
+ assign is_preview_mode = content_for_header contains "foo" or content_for_header contains "bar"
475
+ echo is_preview_mode
476
+ -%}
477
+ LIQUID
478
+
479
+ context = { "content_for_header" => "Some content" }
480
+
481
+ # Expected output
482
+ # This value should be "false" but it is the value of the variable from the failed expression.
483
+ assert_template_result ( "Some content" , template , context )
484
+
485
+ # This following validation should only be supported with our changes. It is the short-hand for the above template.
486
+ # The validation for it is the expected correct output.
487
+ template = Liquid ::Template . parse ( "{% assign is_preview_mode = content_for_header contains 'foo' or content_for_header contains 'bar' %}{{ is_preview_mode }}" )
488
+ assert_equal ( "false" , template . render ( context ) )
489
+ end
490
+
474
491
private
475
492
476
493
def assert_with_lax_parsing ( template , expected_output , context = { } )
0 commit comments