Skip to content

Commit f154ac1

Browse files
committedMar 5, 2025
More boolean unit tests and enabled more existing parity cases
1 parent 177b79f commit f154ac1

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed
 

‎test/unit/boolean_unit_test.rb

+19-8
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ def test_boolean_assignment_shorthand
9696
end
9797

9898
def test_equality_operators
99-
assert_parity_todo!("1 == 1", "true")
100-
assert_parity_todo!("1 != 2", "true")
99+
assert_parity("1 == 1", "true")
100+
assert_parity("1 != 2", "true")
101101
assert_parity_todo!("'hello' == 'hello'", "true")
102102
end
103103

104104
def test_nil_renders_as_empty_string
105-
assert_parity_todo!("nil", "false")
105+
# No parity needed here. This is to ensure expressions rendered with {{ }}
106+
# will still render as an empty string to preserve pre-existing behavior.
107+
assert_expression("nil", "")
108+
assert_expression("x", "", { "x" => nil })
109+
assert_parity_scenario(:expression, "hello {{ x }}", "hello ", { "x" => nil })
106110
end
107111

108112
def test_nil_comparison_with_blank
@@ -113,11 +117,8 @@ def test_nil_comparison_with_blank
113117
end
114118

115119
def test_if_with_variables
116-
assert_parity_todo!("value", "true", { "value" => true })
117-
assert_parity_todo!("value", "false", { "value" => false })
118-
assert_parity_todo!("value", "false", { "value" => nil })
119-
assert_parity_todo!("value", "true", { "value" => "text" })
120-
assert_parity_todo!("value", "true", { "value" => "" })
120+
assert_parity("value", "true", { "value" => true })
121+
assert_parity("value", "false", { "value" => false })
121122
end
122123

123124
def test_nil_variable_in_and_expression
@@ -130,6 +131,16 @@ def test_boolean_variable_in_and_expression
130131
assert_parity("x and true", "false", { "x" => false })
131132
end
132133

134+
def test_multi_variable_boolean_nil_and_expression
135+
assert_parity("x and y", "false", { "x" => nil, "y" => true })
136+
assert_parity("y and x", "false", { "x" => true, "y" => nil })
137+
end
138+
139+
def test_multi_variable_boolean_nil_or_expression
140+
assert_parity("x or y", "true", { "x" => nil, "y" => true })
141+
assert_parity("y or x", "true", { "x" => true, "y" => nil })
142+
end
143+
133144
private
134145

135146
def assert_parity_todo!(liquid_expression, expected_result, args = {})

0 commit comments

Comments
 (0)
Failed to load comments.