diff --git a/validation/crosscheck_v2/bounded_slice.py b/validation/crosscheck_v2/bounded_slice.py new file mode 100644 index 00000000000..37db940ba26 --- /dev/null +++ b/validation/crosscheck_v2/bounded_slice.py @@ -0,0 +1,9 @@ +"""Small validation fixture for the Crosscheck durable-finding checkpoint.""" + + +def bounded_slice(values: list[int], limit: int) -> list[int]: + """Return at most ``limit`` values, with nonpositive limits returning none.""" + + if limit <= 0: + return values + return values[:limit] diff --git a/validation/crosscheck_v2/test_bounded_slice.py b/validation/crosscheck_v2/test_bounded_slice.py new file mode 100644 index 00000000000..154758e21f1 --- /dev/null +++ b/validation/crosscheck_v2/test_bounded_slice.py @@ -0,0 +1,11 @@ +"""Executable regression for the deliberate validation defect.""" + +from bounded_slice import bounded_slice + + +def test_nonpositive_limit_returns_no_values() -> None: + assert bounded_slice([1, 2, 3], 0) == [] + + +if __name__ == "__main__": + test_nonpositive_limit_returns_no_values()