Skip to content

Commit

Permalink
test: create unit test with no precondition
Browse files Browse the repository at this point in the history
Create test case without function precondition
Refactor certain tests to replace get_paths() to get_edges()
  • Loading branch information
Raine-Yang-UofT committed Sep 27, 2024
1 parent ee18274 commit 2e4ae0f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/test_cfg/test_edge_feasibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,19 @@ def func(x: str) -> None:
print(x)
"""
cfg = _create_cfg(src, "func")
assert all(edge.is_feasible for edge in cfg.get_paths()[0])
assert all(edge.is_feasible for edge in cfg.get_edges())


def test_feasible_no_precondition() -> None:
src = """
def func(x: int) -> None:
print(x)
if x > 5:
print("x greater than 5")
print("end")
"""
cfg = _create_cfg(src, "func")
assert all(edge.is_feasible for edge in cfg.get_edges())


def test_feasible_if_condition() -> None:
Expand Down Expand Up @@ -230,7 +242,7 @@ def func(x: str, y: int) -> None:
print("end")
"""
cfg = _create_cfg(src, "func")
assert all(edge.is_feasible for path in cfg.get_paths() for edge in path)
assert all(edge.is_feasible for edge in cfg.get_edges())


def test_variable_reassignment() -> None:
Expand Down

0 comments on commit 2e4ae0f

Please sign in to comment.