add few test cases for bool (#3949)

* add few test cases for bool

* use parametrize

* use a tuple of strings

Co-authored-by: Masen Furer <m_github@0x26.net>

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
This commit is contained in:
Khaleel Al-Adhami 2024-09-18 13:10:18 -07:00 committed by GitHub
parent d81faf7dad
commit a8734d7392
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -958,6 +958,21 @@ def test_all_number_operations():
)
@pytest.mark.parametrize(
("var", "expected"),
[
(Var.create(False), "false"),
(Var.create(True), "true"),
(Var.create("false"), '("false".split("").length !== 0)'),
(Var.create([1, 2, 3]), "isTrue([1, 2, 3])"),
(Var.create({"a": 1, "b": 2}), 'isTrue(({ ["a"] : 1, ["b"] : 2 }))'),
(Var("mysterious_var"), "isTrue(mysterious_var)"),
],
)
def test_boolify_operations(var, expected):
assert str(var.bool()) == expected
def test_index_operation():
array_var = LiteralArrayVar.create([1, 2, 3, 4, 5])
assert str(array_var[0]) == "[1, 2, 3, 4, 5].at(0)"