diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/data.py b/hypothesis-python/src/hypothesis/internal/conjecture/data.py index b7d07b32ab..3fc6658e08 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/data.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/data.py @@ -1072,9 +1072,17 @@ def __repr__(self): def ir_value_permitted(value, ir_type, kwargs): if ir_type == "integer": - if kwargs["min_value"] is not None and value < kwargs["min_value"]: + min_value = kwargs["min_value"] + max_value = kwargs["max_value"] + shrink_towards = kwargs["shrink_towards"] + if min_value is not None and value < min_value: return False - if kwargs["max_value"] is not None and value > kwargs["max_value"]: + if max_value is not None and value > max_value: + return False + + if (max_value is None or min_value is None) and ( + value - shrink_towards + ).bit_length() >= 128: return False return True diff --git a/hypothesis-python/tests/conjecture/test_ir.py b/hypothesis-python/tests/conjecture/test_ir.py index 90f7cf9f05..f403ca4fc6 100644 --- a/hypothesis-python/tests/conjecture/test_ir.py +++ b/hypothesis-python/tests/conjecture/test_ir.py @@ -523,9 +523,21 @@ def test_all_children_are_permitted_values(ir_type_and_kwargs): @pytest.mark.parametrize( "value, ir_type, kwargs, permitted", [ - (0, "integer", {"min_value": 1, "max_value": 2}, False), - (2, "integer", {"min_value": 0, "max_value": 1}, False), - (10, "integer", {"min_value": 0, "max_value": 20}, True), + (0, "integer", {"min_value": 1, "max_value": 2, "shrink_towards": 0}, False), + (2, "integer", {"min_value": 0, "max_value": 1, "shrink_towards": 0}, False), + (10, "integer", {"min_value": 0, "max_value": 20, "shrink_towards": 0}, True), + ( + int(2**128 / 2) - 1, + "integer", + {"min_value": None, "max_value": None, "shrink_towards": 0}, + True, + ), + ( + int(2**128 / 2), + "integer", + {"min_value": None, "max_value": None, "shrink_towards": 0}, + False, + ), ( math.nan, "float",