Skip to content

Commit

Permalink
Boolean And should return first falsey value (#56)
Browse files Browse the repository at this point in the history
* add test for boolean And
* Use empty string for boolean and test
* Fix return value of boolean And
  • Loading branch information
readevalprint authored and danthedeckie committed Jun 19, 2019
1 parent bdb5d7d commit b47858d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion simpleeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _eval_boolop(self, node):
for value in node.values:
vout = self._eval(value)
if not vout:
return False
return vout
return vout
elif isinstance(node.op, ast.Or):
for value in node.values:
Expand Down
1 change: 1 addition & 0 deletions test_simpleeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_maths_with_ints(self):
self.t("100 % 9", 1)

def test_bools_and_or(self):
self.t('True and ""', "")
self.t('True and False', False)
self.t('True or False', True)
self.t('False or False', False)
Expand Down

0 comments on commit b47858d

Please sign in to comment.