def test_cache_memoize_arg_normalization(cache):
    """
    Test taht cache.memoize() normalizes argument ordering for positional and keyword
    arguments.
    """

    @cache.memoize(typed=True)
    def func(a, b, c, d, **kargs):
        return (a, b, c, d)

    for args, kargs in (
        ((1, 2, 3, 4), {"e": 5}),
        ((1, 2, 3), {"d": 4, "e": 5}),
        ((1, 2), {"c": 3, "d": 4, "e": 5}),
        ((1,), {"b": 2, "c": 3, "d": 4, "e": 5}),
        ((), {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}),
        ((), {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}),
    ):
        func(*args, **kargs)
        assert len(cache) == 1