Skip to content

Commit

Permalink
Add more logical expression tests cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Feb 11, 2024
1 parent b7d23a7 commit 23118e0
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions liquid/golden/if_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,76 @@
error=False,
strict=True,
),
Case(
description="empty array equals special empty",
template="{% if x == empty %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={"x": []},
partials={},
error=False,
strict=False,
),
Case(
description="empty array is truthy",
template="{% if x %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={"x": []},
partials={},
error=False,
strict=False,
),
Case(
description="empty object equals special empty",
template="{% if x == empty %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={"x": {}},
partials={},
error=False,
strict=False,
),
Case(
description="empty object is truthy",
template="{% if x %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={"x": {}},
partials={},
error=False,
strict=False,
),
Case(
description="empty string is truthy",
template="{% if '' %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={},
partials={},
error=False,
strict=False,
),
Case(
description="string contains int",
template="{% if 'hel9lo' contains 9 %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={"x": {}},
partials={},
error=False,
strict=False,
),
Case(
description="undefined is equal to nil",
template="{% if nosuchthing == nil %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={},
partials={},
error=False,
strict=False,
),
Case(
description="undefined is equal to null",
template="{% if nosuchthing == null %}TRUE{% else %}FALSE{% endif %}",
expect="TRUE",
globals={},
partials={},
error=False,
strict=False,
),
]

0 comments on commit 23118e0

Please sign in to comment.