From a8734d7392b09a58aedb84f0cf61424eccdc431e Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Wed, 18 Sep 2024 13:10:18 -0700 Subject: [PATCH] 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 --------- Co-authored-by: Masen Furer --- tests/test_var.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_var.py b/tests/test_var.py index e73407bb0..b6f82a3ea 100644 --- a/tests/test_var.py +++ b/tests/test_var.py @@ -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)"