1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
from __future__ import generator_stop
from utils import check_on_input
MAP_1_ARG = (
"""\
map(*args)
""",
"""\
from __future__ import absolute_import
from six.moves import map
list(map(*args))
""",
)
MAP_2_ARGS = (
"""\
map(x, [1])
""",
"""\
from __future__ import absolute_import
from six.moves import map
list(map(x, [1]))
""",
)
MAP_3_ARGS = (
"""\
map(x, [1], [2])
""",
"""\
from __future__ import absolute_import
from six.moves import map
list(map(x, [1], [2]))
""",
)
MAP_4_ARGS = (
"""\
map(x, [1], [2], [3])
""",
"""\
from __future__ import absolute_import
from six.moves import map
list(map(x, [1], [2], [3]))
""",
)
MAP_REF = (
"""\
x = map
""",
"""\
x = map
""",
)
MAP_ITERATOR_CONTEXT = (
"""\
for a in map(x, [1]):
pass
""",
"""\
from __future__ import absolute_import
from six.moves import map
for a in map(x, [1]):
pass
""",
)
MAP_LAMBDA = (
"""\
x = map(lambda x: x+1, stuff)
""",
"""\
x = [x+1 for x in stuff]
""",
)
def test_map_1_arg():
check_on_input(*MAP_1_ARG)
def test_map_2_args():
check_on_input(*MAP_2_ARGS)
def test_map_3_args():
check_on_input(*MAP_3_ARGS)
def test_map_4_args():
check_on_input(*MAP_4_ARGS)
def test_map_ref():
check_on_input(*MAP_REF)
def test_map_iterator_context():
check_on_input(*MAP_ITERATOR_CONTEXT)
def test_map_lambda():
check_on_input(*MAP_LAMBDA)
|