# ===----------------------------------------------------------------------=== #
# Copyright (c) 2026, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===----------------------------------------------------------------------=== #
"""Implements the list strategy for generating random `List` values in property tests."""

from std.testing.prop.random import Rng
from std.builtin.simd import SIMD
from std.collections import List


__extension List:
    @staticmethod
    def strategy[
        StrategyType: Strategy
    ](
        var strategy: StrategyType,
        *,
        min_len: Int = 0,
        max_len: Int = Int.MAX,
    ) raises -> _ListStrategy[StrategyType]:
        """Returns a strategy for generating lists with random elements.

        Parameters:
            StrategyType: The type of the strategy to use for generating random elements.

        Args:
            strategy: The strategy to use for generating random elements.
            min_len: The minimum length of the list.
            max_len: The maximum length of the list.

        Returns:
            A strategy for generating lists with random elements.

        Raises:
            If the minimum length is greater than the maximum length.
        """
        return _ListStrategy(strategy^, min_len=min_len, max_len=max_len)


struct _ListStrategy[T: Strategy](Movable, Strategy):
    comptime Value = List[Self.T.Value]
