Пример #1
0
def suite_test():
    """Executes the main test suite."""
    assert (plus)(1, 1) == 2 == (_coconut.operator.add)(1, 1)
    assert (plus)("1", "1") == "11" == (_coconut.operator.add)("1", "1")
    assert (mod)(3, 6) == 3 == (_coconut.operator.mod)(3, 6)
    assert (mod)(5, 4) == 1 == (mod_)(5, 4)
    assert (mod)(5, (plus)(2, 2)) == 1 == (_coconut.operator.mod)(5, (_coconut.operator.add)(2, 2))
    assert (base)("11", 2) == 3
    assert (int)("10A", 12) == 154
    assert (join_with)(["1", "2"], ", ") == "1, 2"
    assert (join_with)(["a", "b", "c"]) == "abc"
    assert (len)(_coconut.set(("a", 5))) == 2
    assert _coconut.operator.mul(2, swap2(_coconut_minus)(2, 5)) == 6 == _coconut.operator.mul(2, swap2_(_coconut_minus)(2, 5))
    assert all(same((1, 2, 3), [1, 2, 3]))
    assert (list)(chain2((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2)), (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 3, lambda: 4)))) == [1, 2, 3, 4]
    assert _coconut.functools.partial(threeple, 1, 2)(3) == (1, 2, 3)
    assert (prod)((range)(1, 5)) == 24
    assert plus1(4) == 5 == plus1_(4)
    assert (plus1)(2) == 3 == plus1(2)
    assert plus1(plus1(5)) == 7 == (_coconut_compose(plus1, plus1))(5)
    assert (sqrt)(16) == 4 == (sqrt_)(16)
    assert (square)(3) == 9
    assert sqplus1(3) == 10 == (_coconut_compose(plus1, square))(3)
    assert (plus1sq)(3) == 16 == (plus1sq_)(3)
    assert (sqplus1)(3) == 10 == (sqplus1_)(3)
    assert (square)((plus1)(3)) == 16 == (square)((plus1_)(3))
    assert reduce(_coconut_pipe, [3, plus1, square]) == 16 == pipe(pipe(3, plus1), square)
    assert reduce(_coconut_compose, [sqrt, square, plus1])(3) == 4 == compose(compose(sqrt, square), plus1)(3)
    assert sum_([1, 7, 3, 5]) == 16
    assert ((list)(add([1, 2, 3], [10, 20, 30])) == [11, 22, 33] == (list)(zipsum([1, 2, 3], [10, 20, 30])))
    assert clean("   ab cd ef   ") == "ab cd ef" == (clean)("   ab cd ef   ")
    assert ((add2)(2))(3) == 5
    for qsort in [qsort1, qsort2, qsort3, qsort4, qsort5]:
        to_sort = rand_list(10)
        assert (tuple)((qsort)(to_sort)) == (tuple)((sorted)(to_sort))
    assert _coconut_igetitem(repeat(3), 2) == 3 == _coconut_igetitem(repeat_(3), 2)
    assert sum_(_coconut_igetitem(repeat(1), _coconut.slice(None, 5))) == 5 == sum_(_coconut_igetitem(repeat_(1), _coconut.slice(None, 5)))
    assert (sum_(takewhile(lambda x: x < 5, N())) == 10 == (sum)(_coconut_igetitem(dropwhile(_coconut.functools.partial(_coconut.operator.gt, 0), (_coconut.itertools.chain.from_iterable((_coconut_lazy_item() for _coconut_lazy_item in (lambda: range(-10, 0), lambda: N()))))), _coconut.slice(None, 5))))
    assert (sum_)(((lambda s: map(_coconut.functools.partial(_coconut.operator.getitem, s), (1, 3, 5))))("ABCDEFG")) == "BDF"
    assert (list)(_coconut_igetitem(N(), _coconut.slice(10, 15))) == [10, 11, 12, 13, 14] == (list)(_coconut_igetitem(N_(), _coconut.slice(10, 15)))
    assert ((list)(takewhile(_coconut.functools.partial(_coconut.operator.gt, 5), N())) == [0, 1, 2, 3, 4] == (list)(_coconut_igetitem(range(0, 10), _coconut.slice(None, 5, None))))
    assert (sum)(_coconut_igetitem((_coconut.itertools.chain.from_iterable((_coconut_lazy_item() for _coconut_lazy_item in (lambda: range(-10, 0), lambda: N())))), _coconut.slice(5, 15))) == -5 == (sum)(_coconut_igetitem(chain(range(-10, 0), N()), _coconut.slice(5, 15)))
    assert (list)(_coconut_igetitem(add(repeat(1), N()), _coconut.slice(None, 5))) == [1, 2, 3, 4, 5] == (list)(_coconut_igetitem(add(repeat(1), N_()), _coconut.slice(None, 5)))
    assert sum(_coconut_igetitem(_coconut_igetitem(N(), _coconut.slice(5, None)), _coconut.slice(None, 5))) == 35 == sum(_coconut_igetitem(_coconut_igetitem(N_(), _coconut.slice(5, None)), _coconut.slice(None, 5)))
    assert (list)(_coconut.functools.partial(_coconut_igetitem, N())(slice(5, 10))) == [5, 6, 7, 8, 9] == _coconut.functools.partial(_coconut.operator.getitem, list(range(0, 15)))(slice(5, 10))
    assert (list)(_coconut_igetitem(N(), slice(5, 10))) == [5, 6, 7, 8, 9] == list(range(0, 15))[slice(5, 10)]
    assert (list)(_coconut_igetitem(preN(range(-5, 0)), _coconut.slice(1, 10))) == [-4, -3, -2, -1, 0, 1, 2, 3, 4]
    assert (list)(_coconut_igetitem(map_iter(_coconut.functools.partial(_coconut.operator.mul, 2), N()), _coconut.slice(None, 5))) == [0, 2, 4, 6, 8]
    assert (tuple)(_coconut_igetitem(N(), _coconut.slice(None, 100))) == (tuple)(_coconut_igetitem(N_(), _coconut.slice(None, 100))) == (tuple)(_coconut_igetitem(N__(), _coconut.slice(None, 100)))
    assert next_mul_of(5, 12) == 15
    assert collatz(27)
    assert preop(1, 2).add() == 3
    assert (abs)(vector(3, 4)) == 5
    assert (tuple)(((lambda v: map(_coconut.functools.partial(_coconut.getattr, v), ("x", "y"))))(vector(1, 2))) == (1, 2)
    assert (tuple)(((lambda v: map(_coconut.functools.partial(_coconut.operator.getitem, v), (0, 1))))((vector(1, 2).transform)(vector(3, 1)))) == (4, 3)
    assert (vector(1, 2).__eq__)(vector(1, 2))
    assert not (vector(3, 4).__eq__)(vector(1, 2))
    assert not (vector(1, 2).__eq__)((1, 2))
    assert vector(vector(4, 3)) == vector(4, 3)
    assert triangle(3, 4, 5).is_right()
    assert _coconut.getattr(triangle(3, 4, 5), "is_right")
    assert (_coconut.operator.methodcaller("is_right"))(triangle(3, 4, 5))
    assert factorial1(3) == 6
    assert factorial2(3) == 6
    assert factorial4(3) == 6
    assert factorial5(3) == 6
    assert fact(3) == 6
    assert factorial1(-1) is None
    assert factorial2(-1) is None
    assert factorial4(-1) is None
    assert factorial5(-1) is None
    assert factorial3([2, 3]) == [2, 6] == factorial3((2, 3))
    assert classify(()) == "empty tuple"
    assert classify([]) == "empty list"
    assert classify((1,)) == "singleton tuple"
    assert classify([1, 1]) == "duplicate pair list of 1"
    assert classify((1, 2)) == "pair tuple"
    assert classify([1, 2, 3]) == "list"
    assert classify((1, 1, 1)) == "tuple"
    assert classify({}) == "empty dict"
    assert classify({"a": 1}) == "dict"
    assert classify(_coconut.set((0,))) == "set of 0" == classify(_coconut.frozenset((0,)))
    assert classify(_coconut.set((0, 1))) == "set" == classify(_coconut.frozenset((1,)))
    assert classify(_coconut.set()) == "empty set" == classify(_coconut.frozenset())
    assert classify_sequence(()) == "empty"
    assert classify_sequence((1,)) == "singleton"
    assert classify_sequence((1, 1)) == "duplicate pair of 1"
    assert classify_sequence((1, 2)) == "pair"
    assert classify_sequence((1, 2, 3)) == "few"
    assert dictpoint({"x": 1, "y": 2}) == (1, 2)
    assert dictpoint_({"x": 1, "y": 2}) == (1, 2) == dictpoint__({"x": 1, "y": 2})
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), []) == []
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), ()) == ()
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), [0, 1, 2, 3]) == [1, 2, 3, 4]
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), (0, 1, 2, 3)) == (1, 2, 3, 4)
    assert duplicate_first1([1, 2, 3]) == [1, 1, 2, 3]
    assert (list)(duplicate_first2([1, 2, 3])) == [1, 1, 2, 3] == (list)(duplicate_first3([1, 2, 3]))
    assert one_to_five([1, 2, 3, 4, 5]) == [2, 3, 4]
    assert not one_to_five([0, 1, 2, 3, 4, 5])
    assert one_to_five([1, 5]) == []
    assert -4 == neg_square_u(2) != 4 & 0 <= neg_square_u(0) <= 0
    assert is_null(null1())
    assert is_null(null2())
    assert (depth)(empty()) == 0
    assert (depth)(leaf(5)) == 1
    assert (depth)(node(leaf(2), node(empty(), leaf(3)))) == 3
    assert maybes(5, square, plus1) == 26
    assert maybes(None, square, plus1) is None
    assert (square)(2) == 4
    assert (mod)(*(5, 3)) == 2 == (mod)(*(5, 3))
    assert ((Just(5))(square))(plus1) == Just(26)
    assert ((Nothing())(square))(plus1) == Nothing()
    assert head_tail([1, 2, 3]) == (1, [2, 3])
    assert init_last([1, 2, 3]) == ([1, 2], 3)
    assert last_two([1, 2, 3]) == (2, 3) == last_two_([1, 2, 3])
    assert expl_ident(5) == 5
    assert ((_coconut.functools.partial(_coconut.functools.partial, mod))(5))(3) == 2 == ((_coconut.functools.partial(_coconut.functools.partial, _coconut.operator.mod))(5))(3)
    assert (dectest)(5) == 5
    try:
        raise ValueError()
    except (TypeError, ValueError) as err:
        assert err
    else:
        assert False
    assert delist2([1, 2]) == (1, 2) == delist2_([1, 2])
    assert tuple1(1) == (1,) == tuple1_(1)
    assert tuple2(1, 2) == (1, 2) == tuple2_(1, 2)
    assert htsplit([1, 2, 3]) == [1, [2, 3]] == htsplit_([1, 2, 3])
    assert iadd(1, 2) == 3 == iadd_(1, 2)
    assert strmul("a", 3) == "aaa" == strmul_("a", 3)
    try:
        strmul("a", "b")
    except MatchError as err:
        assert err.pattern == "match def strmul(a is str, x is int):"
        assert err.value == ("a", "b")
    else:
        assert False
    laz = lazy()
    assert not laz.done
    lazl = laz.list()
    assert (list)(_coconut_igetitem(lazl, _coconut.slice(None, 3))) == [1, 2, 3]
    assert not laz.done
    assert (list)(lazl) == [None]
    assert laz.done
    assert is_empty(iter(()))
    assert is_empty(())
    assert not is_empty([1])
    assert is_one(iter([1]))
    assert not is_one(iter(()))
    assert not is_one([])
    assert is_one([1])
    assert trilen(3, 4).h == 5 == datamaker(trilen)(5).h
    assert A().true()
    assert B().true()
    assert pt.__doc__
    out0 = grid_trim(grid(), xmax=5, ymax=5)
    assert out0 == [[pt(x=0, y=0), pt(x=0, y=1), pt(x=0, y=2), pt(x=0, y=3), pt(x=0, y=4)], [pt(x=1, y=0), pt(x=1, y=1), pt(x=1, y=2), pt(x=1, y=3), pt(x=1, y=4)], [pt(x=2, y=0), pt(x=2, y=1), pt(x=2, y=2), pt(x=2, y=3), pt(x=2, y=4)], [pt(x=3, y=0), pt(x=3, y=1), pt(x=3, y=2), pt(x=3, y=3), pt(x=3, y=4)], [pt(x=4, y=0), pt(x=4, y=1), pt(x=4, y=2), pt(x=4, y=3), pt(x=4, y=4)]]
    out1 = grid_trim(grid_map(abs, grid()), xmax=5, ymax=5)
    out1_ = (list)(map(list, parallel_grid_map(abs, grid_trim(grid(), xmax=5, ymax=5))))
    assert out1[0] == [0.0, 1.0, 2.0, 3.0, 4.0] == out1_[0]
    assert out1[1][0] == 1.0 == out1_[1][0]
    assert out1[2][0] == 2.0 == out1_[2][0]
    assert out1[3][0] == 3.0 == out1_[3][0]
    assert out1[3][4] == 5.0 == out1_[3][4]
    assert out1[4][0] == 4.0 == out1_[4][0]
    assert out1[4][3] == 5.0 == out1_[4][3]
    x = 5
    x = (square)(x)
    y = square
    y = y((5))
    assert x == 25 == y
    x = (5, 3)
    x = (mod)(*x)
    y = mod
    y = y(*((5, 3)))
    assert x == 2 == y
    x = square
    x = (lambda f, g: lambda *args, **kwargs: f(g(*args, **kwargs)))(x, (_coconut.functools.partial(_coconut.operator.add, 1)))
    x = x((4))
    assert x == 25
    v = vector(1, 2)
    try:
        v.x = 3
    except AttributeError as err:
        assert err
    else:
        assert False
    try:
        v.new_attr = True
    except AttributeError as err:
        assert err
    else:
        assert False
    assert SHOPeriodTerminate([-1, 0], 0, {"epsilon": 1})
    assert add_int_or_str_1(2) == 3 == coercive_add(2, "1")
    assert add_int_or_str_1("2") == "21" == coercive_add("2", 1)
    assert still_ident(3) == 3
    assert not_ident(3) == "bar"
    assert pattern_abs(4) == 4 == pattern_abs_(4)
    assert pattern_abs(0) == 0 == pattern_abs_(0)
    assert pattern_abs(-4) == 4 == pattern_abs_(-4)
    assert _coconut.operator.eq(vector(1, 2), vector(1, 2))
    assert (_coconut.operator.methodcaller("__eq__", other=vector(1, 2)))(vector(1, 2))
    assert (sum)(filter(lambda i: i % 2 == 0, takewhile(lambda i: i < 4000000, fib()))) == 4613732
    assert (list)(_coconut_igetitem(loop([1, 2]), _coconut.slice(None, 4))) == [1, 2] * 2
    assert recurse_n_times(10000)
    assert is_even(5000) and is_odd(5001)
    assert is_even_(5000) and is_odd_(5001)
    def _coconut_lambda_0(_=None):
        return mod
    assert (_coconut_lambda_0)()(5, 3) == 2
    assert (list)(sieve((2, 3, 4, 5))) == [2, 3, 5]
    assert 11 == double_plus_one(5)
    assert 15 == assign_func_1(_coconut.operator.mul, 3, 5)
    assert 15 == assign_func_2(_coconut.operator.mul, 3, 5)
    assert 20 == _coconut_compose(_coconut.functools.partial(minus, 2), _coconut.functools.partial(mul, 2), _coconut.functools.partial(plus, 1))(10)
    assert 20 == (_coconut_compose(_coconut.functools.partial(minus, 2), _coconut.functools.partial(mul, 2), _coconut.functools.partial(plus, 1)))(10)
    assert does_raise_exc(raise_exc)
    assert ret_none(10) is None
    assert anything_func() is None
    assert args_kwargs_func() is None
    return True
Пример #2
0
def suite_test():
    """Executes the main test suite."""
    assert (plus)(1, 1) == 2 == (_coconut.operator.add)(1, 1)
    assert (plus)("1", "1") == "11" == (_coconut.operator.add)("1", "1")
    assert (mod)(3, 6) == 3 == (_coconut.operator.mod)(3, 6)
    assert (mod)(5, 4) == 1 == (mod_)(5, 4)
    assert (plus)((mod)(5, 2), 2) == 3 == (_coconut.operator.add)((_coconut.operator.mod)(5, 2), 2)
    assert (base)("11", 2) == 3
    assert (int)("10A", 12) == 154
    assert (join_with)(["1", "2"], ", ") == "1, 2"
    assert (join_with)(["a", "b", "c"]) == "abc"
    assert (len)(_coconut.set(("a", 5))) == 2
    assert _coconut.operator.mul(2, swap2(_coconut_minus)(2, 5)) == 6 == _coconut.operator.mul(2, swap2_(_coconut_minus)(2, 5))
    assert all(same((1, 2, 3), [1, 2, 3]))
    assert (list)(chain2((_coconut_func() for _coconut_func in (lambda: 1, lambda: 2)), (_coconut_func() for _coconut_func in (lambda: 3, lambda: 4)))) == [1, 2, 3, 4]
    assert _coconut.functools.partial(threeple, 1, 2)(3) == (1, 2, 3)
    assert (product)((range)(1, 5)) == 24
    assert plus1(4) == 5 == plus1_(4)
    assert (plus1)(2) == 3 == plus1(2)
    assert plus1(plus1(5)) == 7 == (_coconut_forward_compose(plus1, plus1))(5)
    assert (sqrt)(16) == 4 == (sqrt_)(16)
    assert (square)(3) == 9
    def test_sqplus1_plus1sq(sqplus1, plus1sq, parallel=True):
        assert sqplus1(3) == 10 == (_coconut_forward_compose(square, plus1))(3), sqplus1
        if parallel:
            assert (tuple)(parallel_map(sqplus1, range(3))) == (1, 2, 5), sqplus1
        assert (plus1sq)(3) == 16, plus1sq
        assert (sqplus1)(3) == 10, sqplus1
    test_sqplus1_plus1sq(sqplus1_1, plus1sq_1)
    test_sqplus1_plus1sq(sqplus1_2, plus1sq_2, parallel=False)
    test_sqplus1_plus1sq(sqplus1_3, plus1sq_3)
    test_sqplus1_plus1sq(sqplus1_4, plus1sq_4)
    assert (square)((plus1)(3)) == 16 == (square)((plus1_)(3))
    assert reduce(_coconut_pipe, [3, plus1, square]) == 16 == pipe(pipe(3, plus1), square)
    assert reduce(_coconut_back_compose, [sqrt, square, plus1])(3) == 4 == compose(compose(sqrt, square), plus1)(3)
    assert sum_([1, 7, 3, 5]) == 16
    assert (list)(add([1, 2, 3], [10, 20, 30])) == [11, 22, 33]
    assert (list)(add_([1, 2, 3], [10, 20, 30])) == [11, 22, 33]
    assert (list)(zipsum([1, 2, 3], [10, 20, 30])) == [11, 22, 33]
    assert clean("   ab cd ef   ") == "ab cd ef" == (clean)("   ab cd ef   ")
    assert ((add2)(2))(3) == 5
    qsorts = [qsort1, qsort2, qsort3, qsort4, qsort5, qsort6, qsort7, qsort8]
    for qsort in qsorts:
        to_sort = rand_list(10)
        assert (tuple)((qsort)(to_sort)) == (tuple)((sorted)(to_sort)), qsort
    to_sort = rand_list(10)
    assert (list)(parallel_map(_coconut_base_compose(_coconut.functools.partial(_coconut_pipe, to_sort), (tuple, 0)), qsorts)) == [(tuple)((sorted)(to_sort))] * len(qsorts)
    assert _coconut_igetitem(repeat(3), 2) == 3 == _coconut_igetitem(repeat_(3), 2)
    assert sum_(_coconut_igetitem(repeat(1), _coconut.slice(None, 5))) == 5 == sum_(_coconut_igetitem(repeat_(1), _coconut.slice(None, 5)))
    assert (sum_(takewhile(lambda x: x < 5, N())) == 10 == (sum)(_coconut_igetitem(dropwhile(_coconut.functools.partial(_coconut.operator.gt, 0), (_coconut.itertools.chain.from_iterable((_coconut_func() for _coconut_func in (lambda: range(-10, 0), lambda: N()))))), _coconut.slice(None, 5))))
    assert (sum_)(((lambda s: map(_coconut.functools.partial(_coconut.operator.getitem, s), (1, 3, 5))))("ABCDEFG")) == "BDF"  # type: ignore
    assert (list)(_coconut_igetitem(N(), _coconut.slice(10, 15))) == [10, 11, 12, 13, 14] == (list)(_coconut_igetitem(N_(), _coconut.slice(10, 15)))
    assert ((list)(takewhile(_coconut.functools.partial(_coconut.operator.gt, 5), N())) == [0, 1, 2, 3, 4] == (list)(_coconut_igetitem(range(0, 10), _coconut.slice(None, 5, None))))
    assert (sum)(_coconut_igetitem((_coconut.itertools.chain.from_iterable((_coconut_func() for _coconut_func in (lambda: range(-10, 0), lambda: N())))), _coconut.slice(5, 15))) == -5 == (sum)(_coconut_igetitem(chain(range(-10, 0), N()), _coconut.slice(5, 15)))
    assert (list)(_coconut_igetitem(add(repeat(1), N()), _coconut.slice(None, 5))) == [1, 2, 3, 4, 5] == (list)(_coconut_igetitem(add_(repeat(1), N_()), _coconut.slice(None, 5)))
    assert sum(_coconut_igetitem(_coconut_igetitem(N(), _coconut.slice(5, None)), _coconut.slice(None, 5))) == 35 == sum(_coconut_igetitem(_coconut_igetitem(N_(), _coconut.slice(5, None)), _coconut.slice(None, 5)))
    assert (list)(_coconut.functools.partial(_coconut_igetitem, N())(slice(5, 10))) == [5, 6, 7, 8, 9] == _coconut.functools.partial(_coconut.operator.getitem, list(range(0, 15)))(slice(5, 10))
    assert (list)(_coconut_igetitem(N(), slice(5, 10))) == [5, 6, 7, 8, 9] == list(range(0, 15))[slice(5, 10)]
    assert (list)(_coconut_igetitem(preN(range(-5, 0)), _coconut.slice(1, 10))) == [-4, -3, -2, -1, 0, 1, 2, 3, 4]
    assert (list)(_coconut_igetitem(map_iter(_coconut.functools.partial(_coconut.operator.mul, 2), N()), _coconut.slice(None, 5))) == [0, 2, 4, 6, 8]
    assert (tuple)(_coconut_igetitem(N(), _coconut.slice(None, 100))) == (tuple)(_coconut_igetitem(N_(), _coconut.slice(None, 100))) == (tuple)(_coconut_igetitem(N__(), _coconut.slice(None, 100)))
    assert next_mul_of(5, 12) == 15
    assert collatz(27)
    assert preop(1, 2).add() == 3
    assert (abs)(vector(3, 4)) == 5 == (abs)(vector_with_id(3, 4, 1))
    assert (tuple)(((lambda v: map(_coconut.functools.partial(_coconut.getattr, v), ("x", "y"))))(vector(1, 2))) == (1, 2)  # type: ignore
    assert (tuple)(((lambda v: map(_coconut.functools.partial(_coconut.operator.getitem, v), (0, 1))))((vector(1, 2).transform)(vector(3, 1)))) == (4, 3)  # type: ignore
    assert (vector(1, 2).__eq__)(vector(1, 2))
    assert not (vector(3, 4).__eq__)(vector(1, 2))
    assert not (vector(1, 2).__eq__)((1, 2))
    assert vector(vector(4, 3)) == vector(4, 3)
    assert not vector(4, 3) != vector(4, 3)
    assert not vector(1, 2) == (1, 2)
    assert not vector(2, 3) != vector(2, 3)
    assert vector(1, 2) != (1, 2)
    assert vector(1, 2) + vector(2, 3) == vector(3, 5)
    assert vector(1, 2) + 1 == vector(2, 3)
    assert triangle(3, 4, 5).is_right()
    assert _coconut.getattr(triangle(3, 4, 5), "is_right")
    assert (_coconut.operator.methodcaller("is_right"))(triangle(3, 4, 5))
    assert (triangle(3, 4, 5)).is_right()
    def test_factorial(factorial, test_none=True):
        assert factorial(0) == 1 == factorial(1)
        assert factorial(3) == 6
        if test_none:
            assert factorial(-1) is None
    test_factorial(factorial1)
    test_factorial(factorial2)
    test_factorial(factorial4)
    test_factorial(factorial5)
    test_factorial(fact, test_none=False)
    test_factorial(fact_, test_none=False)
    test_factorial(factorial, test_none=False)
    assert factorial3([2, 3]) == [2, 6] == factorial3((2, 3))
    assert classify(()) == "empty tuple"
    assert classify([]) == "empty list"
    assert classify((1,)) == "singleton tuple"
    assert classify([1, 1]) == "duplicate pair list of 1"
    assert classify((1, 2)) == "pair tuple"
    assert classify([1, 2, 3]) == "list"
    assert classify((1, 1, 1)) == "tuple"
    assert classify({}) == "empty dict"
    assert classify({"a": 1}) == "dict"
    assert classify(_coconut.set((0,))) == "set of 0" == classify(_coconut.frozenset((0,)))
    assert classify(_coconut.set((0, 1))) == "set" == classify(_coconut.frozenset((1,)))
    assert classify(_coconut.set()) == "empty set" == classify(_coconut.frozenset())
    assert classify_sequence(()) == "empty"
    assert classify_sequence((1,)) == "singleton"
    assert classify_sequence((1, 1)) == "duplicate pair of 1"
    assert classify_sequence((1, 2)) == "pair"
    assert classify_sequence((1, 2, 3)) == "few"
    assert dictpoint({"x": 1, "y": 2}) == (1, 2)
    assert dictpoint_({"x": 1, "y": 2}) == (1, 2) == dictpoint__({"x": 1, "y": 2})
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), []) == []
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), ()) == ()
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), [0, 1, 2, 3]) == [1, 2, 3, 4]
    assert map_(_coconut.functools.partial(_coconut.operator.add, 1), (0, 1, 2, 3)) == (1, 2, 3, 4)
    assert duplicate_first1([1, 2, 3]) == [1, 1, 2, 3]
    assert (list)(duplicate_first2([1, 2, 3])) == [1, 1, 2, 3] == (list)(duplicate_first3([1, 2, 3]))
    assert one_to_five([1, 2, 3, 4, 5]) == [2, 3, 4]
    assert not one_to_five([0, 1, 2, 3, 4, 5])
    assert one_to_five([1, 5]) == []
    assert -4 == neg_square_u(2) != 4 & 0 <= neg_square_u(0) <= 0
    assert is_null(null1())
    assert is_null(null2())
    assert (depth)(empty()) == 0
    assert (depth)(leaf(5)) == 1
    assert (depth)(node(leaf(2), node(empty(), leaf(3)))) == 3
    assert maybes(5, square, plus1) == 26
    assert maybes(None, square, plus1) is None
    assert (square)(2) == 4
    assert (mod)(*(5, 3)) == 2 == (mod)(*(5, 3))
    assert ((Just(5))(square))(plus1) == Just(26)
    assert ((Nothing())(square))(plus1) == Nothing()
    assert not Nothing() == ()
    assert not Nothing() != Nothing()
    assert Nothing() != ()
    assert not Just(1) == (1,)
    assert not Just(1) != Just(1)
    assert Just(1) != (1,)
    assert head_tail([1, 2, 3]) == (1, [2, 3])
    assert init_last([1, 2, 3]) == ([1, 2], 3)
    assert last_two([1, 2, 3]) == (2, 3) == last_two_([1, 2, 3])
    assert expl_ident(5) == 5
    assert ((_coconut.functools.partial(_coconut.functools.partial, mod))(5))(3) == 2 == ((_coconut.functools.partial(_coconut.functools.partial, _coconut.operator.mod))(5))(3)
    assert (dectest)(5) == 5
    try:
        raise ValueError()
    except (TypeError, ValueError) as err:
        assert err
    else:
        assert False
    assert delist2([1, 2]) == (1, 2) == delist2_([1, 2])
    assert tuple1(1) == (1,) == tuple1_(1)
    assert tuple2(1, 2) == (1, 2) == tuple2_(1, 2)
    assert htsplit([1, 2, 3]) == [1, [2, 3]] == htsplit_([1, 2, 3])
    assert iadd(1, 2) == 3 == iadd_(1, 2)
    assert strmul("a", 3) == "aaa" == strmul_("a", 3)
    try:
        strmul("a", "b")
    except MatchError as err:
        assert err.pattern == "match def strmul(a is str, x is int):"
        assert err.value == ("a", "b")
    else:
        assert False
    laz = lazy()
    assert not laz.done
    lazl = laz.list()
    assert (list)(_coconut_igetitem(lazl, _coconut.slice(None, 3))) == [1, 2, 3]
    assert not laz.done
    assert (list)(lazl) == [None]
    assert laz.done
    assert is_empty(iter(()))
    assert is_empty(())
    assert not is_empty([1])
    assert is_one(iter([1]))
    assert not is_one(iter(()))
    assert not is_one([])
    assert is_one([1])
    assert trilen(3, 4).h == 5 == datamaker(trilen)(5).h
    assert A().true()
    assert B().true()
    assert pt.__doc__
    out0 = grid_trim(grid(), xmax=5, ymax=5)
    assert out0 == [[pt(x=0, y=0), pt(x=0, y=1), pt(x=0, y=2), pt(x=0, y=3), pt(x=0, y=4)], [pt(x=1, y=0), pt(x=1, y=1), pt(x=1, y=2), pt(x=1, y=3), pt(x=1, y=4)], [pt(x=2, y=0), pt(x=2, y=1), pt(x=2, y=2), pt(x=2, y=3), pt(x=2, y=4)], [pt(x=3, y=0), pt(x=3, y=1), pt(x=3, y=2), pt(x=3, y=3), pt(x=3, y=4)], [pt(x=4, y=0), pt(x=4, y=1), pt(x=4, y=2), pt(x=4, y=3), pt(x=4, y=4)]]
    out1 = grid_trim(grid_map(abs, grid()), xmax=5, ymax=5)
    out1_ = (list)(map(list, parallel_grid_map(abs, grid_trim(grid(), xmax=5, ymax=5))))
    assert out1[0] == [0.0, 1.0, 2.0, 3.0, 4.0] == out1_[0]
    assert out1[1][0] == 1.0 == out1_[1][0]
    assert out1[2][0] == 2.0 == out1_[2][0]
    assert out1[3][0] == 3.0 == out1_[3][0]
    assert out1[3][4] == 5.0 == out1_[3][4]
    assert out1[4][0] == 4.0 == out1_[4][0]
    assert out1[4][3] == 5.0 == out1_[4][3]
    x = 5
    x = (square)(x)
    y = square
    y = y((5))
    assert x == 25 == y
    x = (5, 3)
    x = (mod)(*x)
    y = mod
    y = y(*((5, 3)))
    assert x == 2 == y
    x = square
    x = _coconut_forward_compose((_coconut.functools.partial(_coconut.operator.add, 1)), x)
    x = x((4))
    assert x == 25
    v = vector(1, 2)
    try:
        v.x = 3
    except AttributeError as err:
        assert err
    else:
        assert False
    try:
        v.new_attr = True
    except AttributeError as err:
        assert err
    else:
        assert False
    assert SHOPeriodTerminate([-1, 0], 0, {"epsilon": 1})
    assert add_int_or_str_1(2) == 3 == coercive_add(2, "1")
    assert add_int_or_str_1("2") == "21" == coercive_add("2", 1)
    assert still_ident(3) == 3
    assert not_ident(3) == "bar"
    assert pattern_abs(4) == 4 == pattern_abs_(4)
    assert pattern_abs(0) == 0 == pattern_abs_(0)
    assert pattern_abs(-4) == 4 == pattern_abs_(-4)
    assert _coconut.operator.eq(vector(1, 2), vector(1, 2))
    assert (vector(1, 2)).__eq__(other=vector(1, 2))
    assert (tuple)(_coconut_igetitem(fibs(), _coconut.slice(1, 4))) == (1, 2, 3)
    assert (sum)(filter(lambda i: i % 2 == 0, takewhile(lambda i: i < 4000000, fibs()))) == 4613732
    assert (list)(_coconut_igetitem(loop([1, 2]), _coconut.slice(None, 4))) == [1, 2] * 2
    assert (tuple)(_coconut_igetitem(parallel_map(_coconut_forward_compose(loop, _coconut.functools.partial(_coconut_igetitem, index=_coconut.slice(None, 2)), list), ([1], [2])), _coconut.slice(None, 2))) == ([1, 1], [2, 2])
    def _coconut_lambda_0(_=None):
        return mod
    assert (_coconut_lambda_0)()(5, 3) == 2
    assert (list)(sieve((2, 3, 4, 5))) == [2, 3, 5]
    assert 11 == double_plus_one(5)
    assert 15 == assign_func_1(_coconut.operator.mul, 3, 5)
    assert 15 == assign_func_2(_coconut.operator.mul, 3, 5)
    assert 20 == _coconut_back_compose(_coconut.functools.partial(minus, 2), _coconut.functools.partial(mul, 2), _coconut.functools.partial(plus, 1))(10)
    assert 20 == (_coconut_forward_compose(_coconut.functools.partial(plus, 1), _coconut.functools.partial(mul, 2), _coconut.functools.partial(minus, 2)))(10)
    assert does_raise_exc(raise_exc)
    assert ret_none(10) is None
    assert (_coconut_partial(ret_args_kwargs, {0: 1, 3: 4}, 5, *(6, 7), a="k"))(*(2, 3, 5)) == ((1, 2, 3, 4, 5, 6, 7), {"a": "k"})
    assert anything_func() is None
    assert args_kwargs_func() is None
    assert x_is_int(4) == 4 == x_is_int(x=4)
    try:
        x_is_int(x="herp")
    except MatchError:
        pass
    else:
        assert False
    try:
        x_is_int()
    except MatchError:
        pass
    else:
        assert False
    assert x_as_y(x=2) == (2, 2) == x_as_y(y=2)
    assert x_y_are_int_gt_0(1, 2) == (1, 2) == x_y_are_int_gt_0(x=1, y=2)
    try:
        x_y_are_int_gt_0(1, y=0)
    except MatchError:
        pass
    else:
        assert False
    assert x_is_int_def_0() == 0 == x_is_int_def_0(x=0)
    try:
        x_is_int_def_0("derp")
    except MatchError:
        pass
    else:
        assert False
    assert head_tail_def_none() == (None, []) == head_tail_def_none([None])
    assert kwd_only_x_is_int_def_0() == 0 == kwd_only_x_is_int_def_0(x=0)
    try:
        kwd_only_x_is_int_def_0(1)
    except MatchError:
        pass
    else:
        assert False
    assert no_args_kwargs()
    try:
        no_args_kwargs(1)
    except MatchError:
        pass
    else:
        assert False
    try:
        no_args_kwargs(a=1)
    except MatchError:
        pass
    else:
        assert False
    a = altclass()
    assert a.func(1) == 1
    assert a.zero(10) == 0
    with Vars.using(globals()):
        assert var_one == 1
    try:
        var_one
    except NameError:
        assert True
    else:
        assert False
    assert (Just)(*map(lambda _=None: _ * 2, Just(3))) == Just(6) == fmap(lambda _=None: _ * 2, Just(3))
    assert (Nothing)(*map(lambda _=None: _ * 2, Nothing())) == Nothing() == fmap(lambda _=None: _ * 2, Nothing())
    assert Elems(1, 2, 3) != Elems(1, 2)
    assert (repr)(fmap(times2, map(plus1, (1, 2, 3)))) == (repr)(map(_coconut_forward_compose(plus1, times2), (1, 2, 3)))
    assert (repr)(fmap(plus1, reversed((1, 2, 3)))) == (repr)((reversed)(map(plus1, (1, 2, 3))))
    assert identity[1:2, 2:3] == (slice(1, 2), slice(2, 3))
    assert (identity)[_coconut.slice(1, 2), _coconut.slice(2, 3)] == (slice(1, 2), slice(2, 3))
    assert (_coconut.operator.itemgetter(_coconut.slice(1, 2), _coconut.slice(2, 3)))(identity) == (slice(1, 2), slice(2, 3))
    assert identity.method(*(1,), **{"a": 2}) == ((1,), {"a": 2})
    assert (_coconut.operator.methodcaller("method", *(1,), **{"a": 2}))(identity) == ((1,), {"a": 2})
    assert (identity).method(*(1,), **{"a": 2}) == ((1,), {"a": 2})
    assert identity[1] == 1
    assert identity[1,] == (1,)
    assert container(1) == container(1)
    assert not container(1) != container(1)
    assert container(1) != container(2)
    assert not container(1) == container(2)
    assert container_(1) == container_(1)
    assert not container_(1) != container_(1)
    assert container_(1) != container_(2)
    assert not container_(1) == container_(2)
    t = Tuple_(1, 2)
    assert repr(t) == "Tuple_(*elems=(1, 2))"
    assert t.elems == (1, 2)
    assert isinstance(t.elems, tuple)
    assert fmap(lambda _=None: _ + 1, t) == Tuple_(2, 3)
    _coconut_match_to = t
    _coconut_match_check = False
    if (_coconut.isinstance(_coconut_match_to, Tuple_)) and (_coconut.len(_coconut_match_to) == 2):
        x = _coconut_match_to[0]
        y = _coconut_match_to[1]
        _coconut_match_check = True
    if not _coconut_match_check:
        _coconut_match_val_repr = _coconut.repr(_coconut_match_to)
        _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'Tuple_(x, y) = t'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "..."))
        _coconut_match_err.pattern = 'Tuple_(x, y) = t'
        _coconut_match_err.value = _coconut_match_to
        raise _coconut_match_err

    assert x == 1 and y == 2
    p = Pred("name", 1, 2)
    p_ = Pred_("name", 1, 2)
    assert p.name == "name" == p_.name
    assert p.args == (1, 2) == p_.args
    assert repr(p) in ("Pred(name='name', *args=(1, 2))", "Pred(name=u'name', *args=(1, 2))")
    assert repr(p_) in ("Pred_(name='name', *args=(1, 2))", "Pred_(name=u'name', *args=(1, 2))")
    for Pred_test, p_test in [(Pred, p), (Pred_, p_)]:
        assert isinstance(p_test.args, tuple)
        _coconut_match_to = p_test
        _coconut_match_check = False
        if (_coconut.isinstance(_coconut_match_to, Pred_test)) and (_coconut.len(_coconut_match_to) >= 1):
            name = _coconut_match_to[0]
            args = _coconut_match_to[1:]
            _coconut_match_check = True
        if not _coconut_match_check:
            _coconut_match_val_repr = _coconut.repr(_coconut_match_to)
            _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'Pred_test(name, *args) = p_test'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "..."))
            _coconut_match_err.pattern = 'Pred_test(name, *args) = p_test'
            _coconut_match_err.value = _coconut_match_to
            raise _coconut_match_err

        assert name == "name"
        assert args == (1, 2)
    q = Quant("name", "var", 1, 2)
    q_ = Quant_("name", "var", 1, 2)
    assert q.name == "name" == q_.name
    assert q.var == "var" == q_.var
    assert q.args == (1, 2) == q_.args
    assert repr(q) in ("Quant(name='name', var='var', *args=(1, 2))", "Quant(name=u'name', var=u'var', *args=(1, 2))")
    assert repr(q_) in ("Quant_(name='name', var='var', *args=(1, 2))", "Quant_(name=u'name', var=u'var', *args=(1, 2))")
    for Quant_test, q_test in [(Quant, q), (Quant_, q_)]:
        assert isinstance(q_test.args, tuple)
        _coconut_match_to = q_test
        _coconut_match_check = False
        if (_coconut.isinstance(_coconut_match_to, Quant_test)) and (_coconut.len(_coconut_match_to) >= 2):
            name = _coconut_match_to[0]
            var = _coconut_match_to[1]
            args = _coconut_match_to[2:]
            _coconut_match_check = True
        if not _coconut_match_check:
            _coconut_match_val_repr = _coconut.repr(_coconut_match_to)
            _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'Quant_test(name, var, *args) = q_test'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "..."))
            _coconut_match_err.pattern = 'Quant_test(name, var, *args) = q_test'
            _coconut_match_err.value = _coconut_match_to
            raise _coconut_match_err

        assert name == "name"
        assert var == "var"
        assert args == (1, 2)
    assert fmap(lambda _=None: _ + 1, Pred(0, 1, 2)) == Pred(1, 2, 3)
    assert fmap(lambda _=None: _ + 1, Pred_(0, 1, 2)) == Pred_(1, 2, 3)
    assert fmap(lambda _=None: _ + 1, Quant(0, 1, 2)) == Quant(1, 2, 3)
    assert fmap(lambda _=None: _ + 1, Quant_(0, 1, 2)) == Quant_(1, 2, 3)
    a = Nest()
    assert a.b.c.d == "data"
    assert (_coconut.operator.attrgetter("b.c.d"))(a) == "data"
    assert (a).b.c.d == "data"
    assert a.b.c.m() == "method"
    assert (_coconut_base_compose(_coconut.operator.attrgetter("b.c"), (_coconut.operator.methodcaller("m"), 0)))(a) == "method"
    assert ((a).b.c).m() == "method"
    assert (lambda x: None if x is None else (lambda x: None if x is None else (lambda x: None if x is None else (lambda x: None if x is None else x())(x.m))(x.c))(x.b))(a) == "method"
    assert (lambda x: None if x is None else x.derp.herp)(a.b.c.none) is None
    assert (list)(tco_chain([1, 2, 3])) == ["last"]
    assert (list)(map(tuple, partition([1, 2, 3], 2))) == [(1,), (3, 2)] == (list)(map(tuple, partition_([1, 2, 3], 2)))
    assert myreduce(_coconut.operator.add, (1, 2, 3)) == 6
    assert recurse_n_times(10000)
    assert fake_recurse_n_times(10000)
    a = A()
    assert (_coconut_forward_compose(a.true, _coconut.operator.not_))() is False
    assert 10 % 4 % 3 == 2 == (mod)((mod)(10, 4), 3)
    assert square_times2_plus1(3) == 19 == square_times2_plus1_(3)
    assert plus1_cube(2) == 27
    assert (repr)(_coconut_base_compose(square, (times2, 0), (plus1, 0))) == (repr)(_coconut_base_compose(square, ((_coconut_base_compose(times2, (plus1, 0))), 0)))
    assert (tuple)(starmap(toprint, map(range, range(1, 5)))) == ('0', '0 1', '0 1 2', '0 1 2 3')
    assert (tuple)(fmap(_coconut.operator.methodcaller("strip", " 0"), starmap(toprint, map(range, range(1, 5))))) == ("", "1", "1 2", "1 2 3")
    assert (len)(starmap(toprint, ())) == 0
    assert (starmap(toprint, [(1, 2)]))[0] == "1 2"
    assert (list)((starmap(toprint, [(1, 2), (2, 3), (3, 4)]))[_coconut.slice(1, None)]) == ["2 3", "3 4"]
    assert none_to_ten() == 10 == any_to_ten(1, 2, 3)
    assert int_map(plus1_, range(5)) == [1, 2, 3, 4, 5]
    assert still_ident.__doc__ == "docstring"
    with context_produces(1) as one:
        with context_produces(2) as two:
            assert one == 1
            assert two == 2
    with (context_produces(1)) as one:
        assert one == 1
    assert (raise_exc() if 1 is None else 1) == 1
    try:
        assert (raise_exc() if None is None else None)
    except Exception as err:
        assert str(err) == "raise_exc"
    else:
        assert False
    for u, Point_test in [("", Point), ("_", Point_)]:
        p = Point_test()
        assert p.x == 0 == p.y
        assert repr(p) == "Point{u}(x=0, y=0)".format(u=u)
        p = Point_test(1)
        assert p.x == 1
        assert p.y == 0
        assert repr(p) == "Point{u}(x=1, y=0)".format(u=u)
        p = Point_test(2, 3)
        assert p.x == 2
        assert p.y == 3
        assert repr(p) == "Point{u}(x=2, y=3)".format(u=u)
    try:
        RadialVector()
    except TypeError:
        try:
            RadialVector_()
        except TypeError:
            pass
        else:
            assert False
    else:
        assert False
    rv = RadialVector(1)
    rv_ = RadialVector_(1)
    assert rv.mag == 1 == rv_.mag
    assert rv.angle == 0 == rv_.angle
    assert repr(rv) == "RadialVector(mag=1, angle=0)"
    assert repr(rv_) == "RadialVector_(mag=1, angle=0)"
    for u, ABC_test in [("", ABC), ("_", ABC_)]:
        try:
            ABC_test()
        except TypeError:
            pass
        else:
            assert False
        abc = ABC_test(2)
        assert abc.a == 2
        assert abc.b == 1
        assert abc.c == ()
        assert repr(abc) == "ABC{u}(a=2, b=1, *c=())".format(u=u)
        abc = ABC_test(3, 4, 5)
        assert abc.a == 3
        assert abc.b == 4
        assert abc.c == (5,)
        assert repr(abc) == "ABC{u}(a=3, b=4, *c=(5,))".format(u=u)
        abc = ABC_test(5, 6, 7, 8)
        assert abc.a == 5
        assert abc.b == 6
        assert abc.c == (7, 8)
        assert repr(abc) == "ABC{u}(a=5, b=6, *c=(7, 8))".format(u=u)
    v = vector2(3, 4)
    assert repr(v) == "vector2(x=3, y=4)"
    assert abs(v) == 5
    try:
        v.x = 2
    except AttributeError:
        pass
    else:
        assert False
    v = vector2()
    assert repr(v) == "vector2(x=0, y=0)"
    for obj in (factorial, iadd, collatz, recurse_n_times):
        assert obj.__doc__ == "this is a docstring", obj
    assert list_type((_coconut_func() for _coconut_func in (lambda: 1, lambda: 2))) == "at least 2"
    assert list_type((_coconut_func() for _coconut_func in (lambda: 1,))) == "at least 1"
    assert list_type(_coconut.iter(())) == "empty"
    cnt = counter()
    _coconut_match_to = cnt.inc()
    _coconut_case_check_0 = False
    if _coconut_match_to == 1:
        _coconut_case_check_0 = True
    if _coconut_case_check_0:
        assert False
    if not _coconut_case_check_0:
        if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to) == 0):
            _coconut_case_check_0 = True
        if _coconut_case_check_0:
            assert False
    if not _coconut_case_check_0:
        if _coconut_match_to is None:
            _coconut_case_check_0 = True
        if _coconut_case_check_0:
            pass
    if not _coconut_case_check_0:
        assert False
    assert cnt.count == 1
    assert (list)(plus1sq_all(1, 2, 3)) == [4, 9, 16] == (list)(plus1sq_all_(1, 2, 3))
    assert (list)(sqplus1_all(1, 2, 3)) == [2, 5, 10] == (list)(sqplus1_all_(1, 2, 3))
    assert (list)(square_times2_plus1_all(1, 2)) == [3, 9] == (list)(square_times2_plus1_all_(1, 2))
    assert (list)(plus1_square_times2_all(1, 2)) == [8, 18] == (list)(plus1_square_times2_all_(1, 2))
    assert plus1sqsum_all(1, 2) == 13 == plus1sqsum_all_(1, 2)
    assert sum_list_range(10) == 45
    assert sum2([3, 4]) == 7
    assert ridiculously_recursive(300) == 201666561657114122540576123152528437944095370972927688812965354745141489205495516550423117825 == ridiculously_recursive_(300)
    assert [fib(n) for n in range(16)] == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
    assert fib.cache_info().hits == 28
    assert ((_coconut_back_compose)(plus1, lambda x: x * 2))(4) == 9
    assert (list)(join_pairs1([(1, [2]), (1, [3])]).items()) == [(1, [2, 3])]
    assert (list)(join_pairs2([(1, [2]), (1, [3])]).items()) == [(1, [3, 2])]
    assert return_in_loop(10)
    assert methtest().meth(5) == 5
    assert methtest().tail_call_meth(3) == 3
    def test_match_error_addpattern(*_coconut_match_to_args, **_coconut_match_to_kwargs):
        _coconut_match_check = False
        _coconut_FunctionMatchError = _coconut_get_function_match_error()
        if (_coconut.len(_coconut_match_to_args) <= 1) and (_coconut.sum((_coconut.len(_coconut_match_to_args) > 0, "x" in _coconut_match_to_kwargs)) == 1):
            _coconut_match_temp_0 = _coconut_match_to_args[0] if _coconut.len(_coconut_match_to_args) > 0 else _coconut_match_to_kwargs.pop("x")
            if (_coconut.isinstance(_coconut_match_temp_0, int)) and (not _coconut_match_to_kwargs):
                x = _coconut_match_temp_0
                _coconut_match_check = True
        if not _coconut_match_check:
            _coconut_match_val_repr = _coconut.repr(_coconut_match_to_args)
            _coconut_match_err = _coconut_FunctionMatchError("pattern-matching failed for " "'def test_match_error_addpattern(x is int): raise MatchError()'" " in " + (_coconut_match_val_repr if _coconut.len(_coconut_match_val_repr) <= 500 else _coconut_match_val_repr[:500] + "..."))
            _coconut_match_err.pattern = 'def test_match_error_addpattern(x is int): raise MatchError()'
            _coconut_match_err.value = _coconut_match_to_args
            raise _coconut_match_err

        raise MatchError()
    @addpattern(test_match_error_addpattern)
    def test_match_error_addpattern(x):
        return x
    try:
        test_match_error_addpattern(0)
    except MatchError as err:  # must not be caught inside addpattern
        assert err
    else:
        assert False

    assert (ret_args_kwargs)(**dict(a=1, b=2)) == ((), dict(a=1, b=2)) == _coconut_dubstar_pipe(dict(a=1, b=2), ret_args_kwargs)
    x = dict(a=1, b=2)
    x = (ret_args_kwargs)(**x)
    assert x == ((), dict(a=1, b=2))

    assert (ret_args_kwargs)(**{"a": 1, "b": 2}) == ((), {"a": 1, "b": 2}) == _coconut_back_dubstar_pipe(ret_args_kwargs, {"a": 1, "b": 2})
    f = ret_args_kwargs
    f = f(**({"a": 1, "b": 2}))
    assert f == ((), {"a": 1, "b": 2})

    ret_dict = lambda _=None: dict(x=2)

    assert (_coconut_base_compose(ret_dict, (_coconut.functools.partial(ret_args_kwargs, 1), 2)))() == ((1,), dict(x=2)) == (_coconut_forward_dubstar_compose(ret_dict, _coconut.functools.partial(ret_args_kwargs, 1)))()
    x = ret_dict
    x = _coconut_forward_dubstar_compose(x, (_coconut.functools.partial(ret_args_kwargs, 1)))
    assert x() == ((1,), dict(x=2))

    assert (_coconut_base_compose(ret_dict, (_coconut.functools.partial(ret_args_kwargs, 1), 2)))() == ((1,), dict(x=2)) == (_coconut_back_dubstar_compose(_coconut.functools.partial(ret_args_kwargs, 1), ret_dict))()
    f = _coconut.functools.partial(ret_args_kwargs, 1)
    f = _coconut_forward_dubstar_compose((ret_dict), f)
    assert f() == ((1,), dict(x=2))

    assert fmap(lambda _=None: _ + 1, data1(1)) == data1(2)
    assert data1(1).x == 1
    assert fmap(lambda _=None: _ + 1, data2(1)) == data2(2)
    try:
        data2("a")
    except MatchError as err:
        assert err
    else:
        assert False
    assert data3(1, 2, 3).xs == (1, 2, 3)
    assert data4(x=1, y=2).kws == dict(x=1, y=2)
    assert data5(1, 2, "3").__doc__ == "docstring"
    assert data5(1, 2, "3").attr == 1
    try:
        data5(1, 2, 3)
    except MatchError as err:
        assert err
    else:
        assert False
    assert issubclass(data6, BaseClass)
    assert namedpt("a", 3, 4).mag() == 5
    t = descriptor_test()
    assert t.lam() == t
    assert t.comp() == (t,)
    assert (list)(_coconut_igetitem(t.N(), _coconut.slice(None, 2))) == [(t, 0), (t, 1)]
    return True
Пример #3
0
def main_test():
    """Basic no-dependency tests."""
    assert "\n" == ('''
''') == """
"""
    assert _coconut
    assert "_coconut" in globals()
    assert "_coconut" not in locals()
    x = 5
    assert x == 5
    x == 6
    assert x == 5
    assert r"hello, world" == "hello, world" == "hello," " " "world"
    assert "\n " == """
 """
    assert "\\" "\"" == "\\\""
    assert """

""" == "\n\n"
    assert {"a": 5}["a"] == 5
    a, = [24]
    assert a == 24
    assert set((1, 2, 3)) == _coconut.set((1, 2, 3))
    olist = [0, 1, 2]
    olist[1] += 4
    assert olist == [0, 5, 2]
    assert +5e+5 == +5 * +10**+5
    assert repr(3) == "3" == ascii(3)
    assert _coconut.operator.mul(2, _coconut_minus(2, 5)) == -6
    assert (list)(map(_coconut.functools.partial(pow, 2), (range)(0, 5))) == [1, 2, 4, 8, 16]
    iter1 = range(0, 10)
    iter1, iter2 = tee(iter1)
    assert (list)(_coconut_igetitem(iter1, _coconut.slice(2, 8))) == (list)(_coconut_igetitem(iter2, _coconut.slice(2, 8)))
    data = 5
    assert data == 5
    data = 3
    assert data == 3
    def backslash_test():
        return lambda x: x
    assert 1 == 1 == backslash_test()(1)
    assert (
            "hello"
         == "hello" == 
            'hello'
        )
    def multiline_backslash_test(
                                   x,
                                   y):
        return x + y
    assert multiline_backslash_test(1, 2) == 3
    assert True
    class one_line_class(_coconut.object):
        pass
    assert isinstance(one_line_class(), one_line_class)
    assert ((_coconut.operator.attrgetter("join"))(""))(["1", "2", "3"]) == "123" == ((_coconut.functools.partial(_coconut.getattr, ""))("join"))(["1", "2", "3"])
    assert (_coconut.functools.partial(_coconut.operator.getitem, [1, 2, 3]))(1) == 2 == (_coconut.functools.partial(_coconut_igetitem, [1, 2, 3]))(1)
    assert (_coconut.functools.partial(_coconut.operator.getitem, "123"))(1) == "2" == (_coconut.functools.partial(_coconut_igetitem, "123"))(1)
    assert (list)(_coconut.itertools.chain.from_iterable((_coconut_lazy_item() for _coconut_lazy_item in (lambda: (_coconut_lazy_item() for _coconut_lazy_item in (lambda: -1, lambda: 0)), lambda: range(1, 5))))) == [-1, 0, 1, 2, 3, 4]
    assert (list)(_coconut.itertools.chain.from_iterable((_coconut_lazy_item() for _coconut_lazy_item in (lambda: (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1,)), lambda: (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 2,)))))) == [1, 2]
    assert not isinstance(map(_coconut.functools.partial(_coconut.operator.add, 2), [1, 2, 3]), list)
    assert not isinstance(range(10), list)
    assert isinstance(10**100, int)
    assert chr(1000)
    assert (abs)(3 + 4j) == 5
    assert 3.14j == 3.14j
    assert 10.j == 10.j
    assert 10j == 10j
    assert .001j == .001j
    assert 1e100j == 1e100j
    assert 3.14e-10j == 3.14e-10j
    _coconut_match_check = False
    _coconut_match_to = {"text": "abc", "tags": [1, 2, 3]}
    if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Mapping)) and (_coconut.len(_coconut_match_to) == 2) and ("text" in _coconut_match_to) and ("tags" in _coconut_match_to) and (_coconut.isinstance(_coconut_match_to["tags"], _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to["tags"]) >= 1):
        text = _coconut_match_to["text"]
        rest = _coconut.list(_coconut_match_to["tags"][1:])
        first = _coconut_match_to["tags"][0]
        _coconut_match_check = True
    if not _coconut_match_check:
        _coconut_match_err = _coconut_MatchError("pattern-matching failed for " '\'{"text": text, "tags": [first] + rest} = {"text": "abc", "tags": [1, 2, 3]}\'' " in " + _coconut.repr(_coconut.repr(_coconut_match_to)))
        _coconut_match_err.pattern = '{"text": text, "tags": [first] + rest} = {"text": "abc", "tags": [1, 2, 3]}'
        _coconut_match_err.value = _coconut_match_to
        raise _coconut_match_err

    assert text == "abc"
    assert first == 1
    assert rest == [2, 3]
    assert isinstance("a", str)
    assert isinstance(b"a", bytes)
    global glob_a, glob_b
    glob_a, glob_b = 0, 0
    assert glob_a == 0 == glob_b
    def set_globs(x):
        global glob_a, glob_b
        glob_a, glob_b = x, x
    set_globs(2)
    assert glob_a == 2 == glob_b
    def set_globs_again(x):
        global glob_a, glob_b
        glob_a, glob_b = (x, x)
    set_globs_again(10)
    assert glob_a == 10 == glob_b
    assert _coconut_minus(1) == -1 == _coconut.functools.partial(_coconut_minus, 1)(2)
    assert (_coconut.operator.le)(3, 3)
    assert (list)((consume)(range(10))) == []
    assert (list)(consume(range(10), keep_last=2)) == [8, 9]
    i = int()
    try:
        i.x = 12
    except AttributeError as err:
        assert err
    else:
        assert False
    r = range(10)
    try:
        r.x = 12
    except AttributeError as err:
        assert err
    else:
        assert False
    if _coconut_sys.version_info < (3,):
        import Queue as q
    else:
        import queue as q
    if _coconut_sys.version_info < (3,):
        import __builtin__ as builtins
    else:
        import builtins
    if _coconut_sys.version_info < (3,):
        import email.MIMEBase as _coconut_import
        try:
            email
        except:
            email = _coconut.imp.new_module("email")
        else:
            if not _coconut.isinstance(email, _coconut.types.ModuleType):
                email = _coconut.imp.new_module("email")
        try:
            email.mime
        except:
            email.mime = _coconut.imp.new_module("email.mime")
        else:
            if not _coconut.isinstance(email.mime, _coconut.types.ModuleType):
                email.mime = _coconut.imp.new_module("email.mime")
        email.mime.base = _coconut_import
    else:
        import email.mime.base
    assert q.Queue
    assert builtins.len([1, 1]) == 2
    assert email.mime.base
    if _coconut_sys.version_info < (3,):
        import email.MIMEBase as mimebase
    else:
        from email.mime import base as mimebase
    assert mimebase
    from_err = TypeError()
    try:
        _coconut_raise_from = ValueError()
        _coconut_raise_from.__cause__ = from_err
        raise _coconut_raise_from
    except ValueError as err:
        assert err.__cause__ is from_err
    else:
        assert False
    class doc(_coconut.collections.namedtuple("doc", "")):
        "doc"
        __slots__ = ()
    class doc_(_coconut.collections.namedtuple("doc_", "")):
        """doc"""
        __slots__ = ()
    assert doc.__doc__ == "doc" == doc_.__doc__
    assert 10000000.0 == 10000000.0
    assert (tuple)(_coconut.iter(())) == ()
    import collections
    if _coconut_sys.version_info < (3, 3):
        import collections as _coconut_import
        try:
            collections
        except:
            collections = _coconut.imp.new_module("collections")
        else:
            if not _coconut.isinstance(collections, _coconut.types.ModuleType):
                collections = _coconut.imp.new_module("collections")
        collections.abc = _coconut_import
    else:
        import collections.abc
    assert isinstance([], collections.abc.Sequence)
    assert isinstance(range(1), collections.abc.Sequence)
    assert collections.defaultdict(int)[5] == 0
    assert len(range(10)) == 10
    assert (tuple)((reversed)(range(4))) == (3, 2, 1, 0)
    assert (tuple)(range(5)[1:]) == (1, 2, 3, 4) == (tuple)(_coconut_igetitem(range(5), _coconut.slice(1, None)))
    assert (tuple)(range(10)[-3:-1]) == (7, 8) == (tuple)(_coconut_igetitem(range(10), _coconut.slice(-3, -1)))
    assert (tuple)(_coconut_igetitem(map(abs, (1, -2, -5, 2)), _coconut.slice(None, None))) == (1, 2, 5, 2)
    assert _coconut_igetitem((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2)), -1) == 2
    assert (tuple)(_coconut_igetitem((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 0, lambda: 1, lambda: 2, lambda: 3)), _coconut.slice(-2, None))) == (2, 3)
    assert (tuple)(_coconut_igetitem((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 0, lambda: 1, lambda: 2, lambda: 3)), _coconut.slice(None, -2))) == (0, 1)
    assert _coconut_igetitem(map(_coconut.operator.add, (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 10, lambda: 20)), (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2))), -1) == 22 == map(_coconut.operator.add, (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 10, lambda: 20)), (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2)))[-1]
    assert _coconut_igetitem(map(lambda x: x + 1, range(10**9)), -1) == 10**9 == _coconut_igetitem(count(), 10**9)
    assert (tuple)(_coconut_igetitem(count(), _coconut.slice(10, 15))) == (10, 11, 12, 13, 14) == (tuple)(count()[10:15])
    assert (tuple)(zip((1, 2), (3, 4))) == ((1, 3), (2, 4)) == (tuple)(_coconut_igetitem(zip((1, 2), (3, 4)), _coconut.slice(None, None)))
    assert (tuple)(_coconut_igetitem(zip((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 10, lambda: 20)), (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2))), -1)) == (20, 2) == (tuple)(zip((_coconut_lazy_item() for _coconut_lazy_item in (lambda: 10, lambda: 20)), (_coconut_lazy_item() for _coconut_lazy_item in (lambda: 1, lambda: 2)))[-1])
    assert (tuple)(_coconut_igetitem(zip(count(), count()), 10**9)) == (10**9, 10**9) == (tuple)(zip(count(), count())[10**9])
    assert _coconut_igetitem(count(1.5, 0.5), 0) == 1.5 == _coconut_igetitem((1.5, 2, 2.5, 3), 0)
    assert (tuple)(_coconut_igetitem(count(1.5, 0.5), _coconut.slice(1, 3))) == (2, 2.5) == (tuple)(_coconut_igetitem((1.5, 2, 2.5, 3), _coconut.slice(1, 3)))
    assert (tuple)(_coconut_igetitem(iter((0, 1, 2, 3, 4)), _coconut.slice(None, None, 2))) == (0, 2, 4)
    assert (tuple)(_coconut_igetitem(iter((0, 1, 2, 3, 4)), _coconut.slice(None, None, -1))) == (4, 3, 2, 1, 0)
    assert dict(((x), (x)) for x in range(5)) == {0: 0, 1: 1, 2: 2, 3: 3, 4: 4}
    _coconut_match_check = False
    _coconut_match_to = 12
    x = _coconut_match_to
    _coconut_match_check = True
    if not _coconut_match_check:
        _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'match x = 12'" " in " + _coconut.repr(_coconut.repr(_coconut_match_to)))
        _coconut_match_err.pattern = 'match x = 12'
        _coconut_match_err.value = _coconut_match_to
        raise _coconut_match_err

    assert x == 12
    get_int = lambda: int
    _coconut_match_check = False
    _coconut_match_to = 5
    if (_coconut.isinstance(_coconut_match_to, get_int())):
        x = _coconut_match_to
        _coconut_match_check = True
    if not _coconut_match_check:
        _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'x is get_int() = 5'" " in " + _coconut.repr(_coconut.repr(_coconut_match_to)))
        _coconut_match_err.pattern = 'x is get_int() = 5'
        _coconut_match_err.value = _coconut_match_to
        raise _coconut_match_err

    assert x == 5
    class a(get_int()):
        pass
    assert isinstance(a(), int)
    assert (len)(map(_coconut.operator.add, range(5), range(6))) == 5 == (len)(zip(range(5), range(6)))
    assert map(_coconut_minus, range(5))._func(3) == -3
    assert (tuple)(map(_coconut_minus, range(5))._iters[0]) == (tuple)(range(5)) == (tuple)(zip(range(5), range(6))._iters[0])
    assert repr(zip((0, 1), (1, 2))) == "zip((0, 1), (1, 2))"
    assert repr(map(_coconut_minus, range(5))).startswith("map(")
    assert repr(parallel_map(_coconut_minus, range(5))).startswith("parallel_map(")
    assert (tuple)(parallel_map(_coconut_minus, range(5))) == (0, -1, -2, -3, -4) == (tuple)(_coconut_igetitem(parallel_map(_coconut.functools.partial(map, _coconut_minus), (range(5),)), 0))
    assert (tuple)(map(tuple, parallel_map(zip, (range(2),), (range(2),)))) == (((0, 0), (1, 1)),)
    assert (tuple)(map(_coconut.operator.add, *(range(0, 5), range(5, 10)))) == (5, 7, 9, 11, 13)
    assert (tuple)(parallel_map(_coconut_compose(_coconut.functools.partial(_coconut.operator.mul, 2), _coconut.functools.partial(_coconut.operator.add, 1)), range(5))) == (2, 4, 6, 8, 10)
    assert repr(concurrent_map(_coconut_minus, range(5))).startswith("concurrent_map(")
    assert (tuple)(concurrent_map(_coconut_minus, range(5))) == (0, -1, -2, -3, -4) == (tuple)(_coconut_igetitem(concurrent_map(_coconut.functools.partial(map, _coconut_minus), (range(5),)), 0))
    assert (tuple)(map(tuple, concurrent_map(zip, (range(2),), (range(2),)))) == (((0, 0), (1, 1)),)
    assert (tuple)(map(_coconut.operator.add, *(range(0, 5), range(5, 10)))) == (5, 7, 9, 11, 13)
    assert (tuple)(concurrent_map(_coconut_compose(_coconut.functools.partial(_coconut.operator.mul, 2), _coconut.functools.partial(_coconut.operator.add, 1)), range(5))) == (2, 4, 6, 8, 10)
    assert 0 in range(1)
    assert range(1).count(0) == 1
    assert 2 in range(5)
    assert range(5).count(2) == 1
    assert 10 not in range(3)
    assert range(3).count(10) == 0
    assert 1 in range(1, 2, 3)
    assert range(1, 2, 3).count(1) == 1
    assert range(1, 2, 3).index(1) == 0
    assert range(1, 2, 3)[0] == 1
    assert range(1, 5, 3).index(4) == 1
    assert range(1, 5, 3)[1] == 4
    try:
        range(1, 2, 3).index(2)
    except ValueError as err:
        assert err
    else:
        assert False
    assert 0 in count()
    assert count().count(0) == 1
    assert -1 not in count()
    assert count().count(-1) == 0
    assert 1 not in count(5)
    assert count(5).count(1) == 0
    assert 2 not in count(1, 2)
    assert count(1, 2).count(2) == 0
    try:
        count(1, 2).index(2)
    except ValueError as err:
        assert err
    else:
        assert False
    assert count(1, 3).index(1) == 0
    assert count(1, 3)[0] == 1
    assert count(1, 3).index(4) == 1
    assert count(1, 3)[1] == 4
    assert (len)(map(lambda x: x, [1, 2])) == 2
    assert repr("hello") == "'hello'" == ascii("hello")
    assert (_coconut.operator.methodcaller("index", 1))(count(1, 3)) == 0
    assert _coconut_igetitem(count(1).__copy__(), 0) == 1
    assert _coconut_igetitem(map(_coconut.operator.add, count(1), count(1)).__copy__(), 0) == 2
    assert (tuple)(_coconut_igetitem(zip(count(1), count(1)).__copy__(), 0)) == (1, 1)
    assert (all)(map(lambda t: isinstance(t, count), tee(count())))
    assert (all)(map(lambda t: isinstance(t, range), tee(range(10))))
    assert (all)(map(lambda t: isinstance(t, list), tee([1, 2, 3])))
    assert (lambda _=None: 5)() == 5
    assert (lambda _=None: _[0])([1, 2, 3]) == 1
    assert (list)(_coconut_igetitem(iter(range(10)), _coconut.slice(-5, -8))) == [5, 6]
    assert (list)(_coconut_igetitem(iter(range(10)), _coconut.slice(-2, None))) == [8, 9]
    assert (_coconut.operator.itemgetter(1))(range(1, 5)) == 2 == (_coconut.functools.partial(_coconut_igetitem, index=1))(range(1, 5))
    assert (list)((_coconut.operator.itemgetter(_coconut.slice(None, 5)))(range(10))) == [0, 1, 2, 3, 4] == (list)((_coconut.functools.partial(_coconut_igetitem, index=_coconut.slice(None, 5)))(range(10)))
    def _coconut_lambda_0(x):
        y = x
    assert (list)(map(_coconut_lambda_0, range(10))) == [None] * 10
    def _coconut_lambda_1(x):
        yield x
    assert (list)(map(list, map(_coconut_lambda_1, range(5)))) == [[0], [1], [2], [3], [4]]
    def do_stuff(x):
        return True
    def _coconut_lambda_2(x=3):
        return do_stuff(x)
    assert (_coconut_lambda_2)() is True
    def _coconut_lambda_3(x=4):
        do_stuff(x)
        return x
    assert (_coconut_lambda_3)() == 4
    def _coconut_lambda_4(x=5):
        do_stuff(x)
    assert (_coconut_lambda_4)() is None
    def _coconut_lambda_5(x=6):
        do_stuff(x)
        assert x
    (_coconut_lambda_5)()
    def _coconut_lambda_6(x=7):
        do_stuff(x)
        assert x
        yield x
    assert (list)((_coconut_lambda_6)()) == [7]
    def _coconut_lambda_7(_=None):
        do_stuff(_)
        assert _
        return _
    assert (_coconut_lambda_7)(8) == 8
    def _coconut_lambda_8(x=9):
        return x
    assert (_coconut_lambda_8)() == 9
    def _coconut_lambda_9(x=10):
        do_stuff(x)
        return x
    assert (_coconut_lambda_9)() == 10
    def _coconut_lambda_12(_=None):
        def _coconut_lambda_11(_=None):
            return 11
        return _coconut_lambda_11
    assert (_coconut_lambda_12)()() == 11
    def _coconut_lambda_13(_=None):
        return 12
    def _coconut_lambda_14(_=None):
        return 12
    assert (_coconut_lambda_13)() == 12 == (_coconut_lambda_14)()
    def _coconut_lambda_15(x):
        return lambda _=None: x
    assert (list)(map(lambda _=None: _(), ((_coconut_lambda_15)(x) for x in range(5)))) == [0, 1, 2, 3, 4]
    herpaderp = 5
    def derp():
        herp = 10
        def _coconut_lambda_16(_=None):
            return herpaderp + herp
        return (_coconut_lambda_16)
    assert derp()() == 15
    class abc(_coconut.collections.namedtuple("abc", "xyz")):
        __slots__ = ()
    assert abc(10).xyz == 10
    class aclass(_coconut.object): pass
    assert isinstance(aclass, object)
    assert (_coconut.operator.is_)(*tee((1, 2)))
    assert (_coconut.operator.is_)(*tee(_coconut.frozenset((1, 2))))
    assert (lambda x: 2 / x)(4) == 1 / 2
    _coconut_match_check = False
    _coconut_match_to = range(10)
    if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Iterable)):
        _coconut_match_iter_0 = _coconut.list(_coconut_match_to)
        if (_coconut.len(_coconut_match_iter_0) >= 2):
            b = _coconut_match_iter_0[1:-1]
            a = _coconut_match_iter_0[0]
            c = _coconut_match_iter_0[-1]
            _coconut_match_check = True
    if not _coconut_match_check:
        _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'match [a, *b, c] = range(10)'" " in " + _coconut.repr(_coconut.repr(_coconut_match_to)))
        _coconut_match_err.pattern = 'match [a, *b, c] = range(10)'
        _coconut_match_err.value = _coconut_match_to
        raise _coconut_match_err

    assert a == 0
    assert b == [1, 2, 3, 4, 5, 6, 7, 8]
    assert c == 9
    _coconut_match_check = False
    _coconut_match_to = range(10)
    if (_coconut.isinstance(_coconut_match_to, _coconut.abc.Iterable)):
        _coconut_match_iter_0 = _coconut.list(_coconut_match_to)
        if (_coconut.len(_coconut_match_iter_0) >= 2) and (_coconut_match_iter_0[0] == _coconut_match_iter_0[-1]):
            b = _coconut_match_iter_0[1:-1]
            a = _coconut_match_iter_0[0]
            _coconut_match_check = True
    if _coconut_match_check:
        assert False
    else:
        assert True
    a = 1
    b = 1
    assert a == 1 == b
    assert count(5) == count(5)
    assert count(5) != count(3)
    assert {count(5): True}[count(5)]
    def _coconut_lambda_17(x):
        return x
    assert (_coconut_lambda_17)(1) == 1
    def _coconut_lambda_18(*_coconut_match_to):
        _coconut_match_check = False
        if (_coconut.len(_coconut_match_to) == 1) and (_coconut.isinstance(_coconut_match_to[0], _coconut.abc.Sequence)) and (_coconut.len(_coconut_match_to[0]) >= 1):
            xs = _coconut.list(_coconut_match_to[0][1:])
            x = _coconut_match_to[0][0]
            _coconut_match_check = True
        if not _coconut_match_check:
            _coconut_match_err = _coconut_MatchError("pattern-matching failed for " "'assert (def ([x] + xs) -> x, xs) <| range(5) == (0, [1,2,3,4])'" " in " + _coconut.repr(_coconut.repr(_coconut_match_to)))
            _coconut_match_err.pattern = 'assert (def ([x] + xs) -> x, xs) <| range(5) == (0, [1,2,3,4])'
            _coconut_match_err.value = _coconut_match_to
            raise _coconut_match_err
        return x, xs
    assert ((_coconut_lambda_18))(range(5)) == (0, [1, 2, 3, 4])
    s = "hello"  # type: str
    assert s == "hello"
    return True