Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
And fix missing bits in the ast expression evaluator: * boolean conversion * & and | bit operators
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import print_function | ||
from rcUtilities import eval_expr | ||
|
||
def test_expr(): | ||
expressions = ( | ||
("1+2", 3), | ||
("a+b", "ab"), | ||
("a+'b'", "ab"), | ||
("a in (a, b, 1)", True), | ||
("a in (b, 1)", False), | ||
("a == b", False), | ||
("a == a", True), | ||
("0 == 0", True), | ||
("0 == 1", False), | ||
("0 > 1", False), | ||
("0 < 1", True), | ||
("0 >= 0", True), | ||
("1 >= 0", True), | ||
("1 <= 0", False), | ||
("0 <= 0", True), | ||
("False and False", False), | ||
("True and False", False), | ||
("True and True", True), | ||
("True or False", True), | ||
("True or True", True), | ||
("False or False", False), | ||
("0 & 1", False), | ||
) | ||
for expr, expected in expressions: | ||
result = eval_expr(expr) | ||
print(expr, "=>", result, "expect:", expected) | ||
assert result == expected |