Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
* Fix broken tests LazyOr/LazyAnd - remove guarantees for equivalent results and only test the results converted to booleans
  • Loading branch information
StylishTriangles committed Sep 22, 2021
1 parent 9a0f12b commit c0c00eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pytealext
version = 1.0.0
version = 1.0.1
author = Łukasz Ptak
author_email = lukasz@ulam.io
description = Extra operations for PyTEAL
Expand Down
17 changes: 13 additions & 4 deletions tests/all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# TEAL version to use for testing
VERSION = 4

def Bool(expr: Expr) -> Expr:
return Not(Not(expr))

class MulwDivwTemplate:
def __init__(self):
self.m1 = "TMPL_M1"
Expand Down Expand Up @@ -84,14 +87,16 @@ def test_mulw_divw_no_bound_check():


@given(vals=st.lists(st.integers(min_value=0, max_value=2 ** 64 - 1), min_size=2))
def test_lazyand_equivalence_with_and(vals: list):
def test_lazyand_boolean_equivalence_with_and(vals: list):
"""
Test if LazyAnd and And produce the same outcomes
"""
ast_lazy_and = calc.LazyAnd(*[Int(val) for val in vals])
ast_and = And(*[Int(val) for val in vals])
note(str(ast_lazy_and))
note(compileTeal(ast_lazy_and, Mode.Application, version=VERSION))

# convert to booleans
ast_lazy_and = Bool(ast_lazy_and)
ast_and = Bool(ast_and)

stack_lazy, _ = compile_and_run(ast_lazy_and)
stack_eager, _ = compile_and_run(ast_and)
Expand All @@ -108,13 +113,17 @@ def compile_and_run(ast: Expr, mode=Mode.Application, version=VERSION) -> Tuple[


@given(vals=st.lists(st.integers(min_value=0, max_value=2 ** 64 - 1).map(Int), min_size=2))
def test_lazyor_equivalence_with_or(vals: list):
def test_lazyor_boolean_equivalence_with_or(vals: list):
"""
Test if LazyOr and Or produce the same outcomes
"""
ast_lazy_or = calc.LazyOr(*vals)
ast_or = Or(*vals)

# convert to booleans
ast_lazy_or = Bool(ast_lazy_or)
ast_or = Bool(ast_or)

stack_lazy, _ = compile_and_run(ast_lazy_or)
stack_eager, _ = compile_and_run(ast_or)

Expand Down

0 comments on commit c0c00eb

Please sign in to comment.