# This test code was written by the `hypothesis.extra.ghostwriter` module
# and is provided under the Creative Commons Zero public domain dedication.

import test_expected_output
import typing
from hypothesis import given, reject, strategies as st


@given(seq=st.one_of(st.binary(), st.lists(st.integers())))
def test_idempotent_timsort(seq: typing.Sequence[int]) -> None:
    try:
        result = test_expected_output.timsort(seq=seq)
        repeat = test_expected_output.timsort(seq=result)
    except AssertionError:
        reject()
    assert result == repeat, (result, repeat)
