Skip to content

Commit

Permalink
Update tests for nondeterminism changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pschanely committed Jan 23, 2025
1 parent eb6651b commit 5677594
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
15 changes: 0 additions & 15 deletions crosshair/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,21 +1029,6 @@ def f(ls: list[int]) -> List[int]:
check_states(f, CONFIRMED)


def test_nondeterministic_detected_via_stacktrace() -> None:
_GLOBAL_THING = [True]

def f(i: int) -> int:
"""post: True"""
_GLOBAL_THING[0] = not _GLOBAL_THING[0]
if _GLOBAL_THING[0]:
return -i if i < 0 else i
else:
return -i if i < 0 else i

actual, expected = check_exec_err(f, "NotDeterministic")
assert actual == expected


def test_nondeterministic_detected_via_condition() -> None:
_GLOBAL_THING = [42]

Expand Down
12 changes: 6 additions & 6 deletions crosshair/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,15 @@ def test_check_circular_with_guard(root):
def test_check_not_deterministic(root) -> None:
NOT_DETERMINISTIC_FOO = {
"foo.py": """
_GLOBAL_THING = [True]
_GLOBAL_THING = [42]
def wonky_foo(i: int) -> int:
'''post: True'''
_GLOBAL_THING[0] = not _GLOBAL_THING[0]
if _GLOBAL_THING[0]:
return -i if i < 0 else i
else:
return -i if i < 0 else i
_GLOBAL_THING[0] += 1
if i > _GLOBAL_THING[0]:
pass
return True
_GLOBAL_THING = [True]
def regular_foo(i: int) -> int:
'''post: True'''
Expand Down

0 comments on commit 5677594

Please sign in to comment.