Skip to content

Commit

Permalink
Add a unit test for the expr string representation (#265)
Browse files Browse the repository at this point in the history
* added test for expr string representation

* Update test_ast.py

* Update test_ast.py

* Update test_ast.py
  • Loading branch information
StrikerRUS committed Jul 7, 2020
1 parent 2605449 commit 7ef884f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ def test_exprs_hash():
assert hash(EXPR_WITH_ALL_EXPRS) == hash(expr_copy)


def test_exprs_str():
assert str(EXPR_WITH_ALL_EXPRS) == """
BinVectorNumExpr(BinVectorExpr(VectorVal([
AbsExpr(NumVal(-2),to_reuse=False),
ExpExpr(NumVal(2),to_reuse=False),
LogExpr(NumVal(2),to_reuse=False),
Log1pExpr(NumVal(2),to_reuse=False),
SqrtExpr(NumVal(2),to_reuse=False),
PowExpr(NumVal(2),NumVal(3),to_reuse=False),
TanhExpr(NumVal(1),to_reuse=False),
BinNumExpr(NumVal(0),FeatureRef(0),to_reuse=False)]),
IdExpr(VectorVal([
NumVal(1),NumVal(2),NumVal(3),NumVal(4),NumVal(5),NumVal(6),NumVal(7),
FeatureRef(1)]),to_reuse=False),SUB),
IfExpr(CompExpr(NumVal(2),NumVal(0),GT),NumVal(3),NumVal(4)),MUL)
""".strip().replace("\n", "")


def test_num_val():
assert type(ast.NumVal(1).value) == int
assert type(ast.NumVal(1, dtype=np.float32).value) == np.float32
Expand Down

0 comments on commit 7ef884f

Please sign in to comment.