コード例 #1
0
def test_find_T():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 5, 5), "T"))
    assert output == [
        (View(1, 3, 3), Motion("T", "c")),
        (View(1, 2, 2), Motion("T", "b")),
        (View(1, 1, 1), Motion("T", "a")),
    ]
コード例 #2
0
def test_find_t():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 0, 0), "t"))
    assert output == [
        (View(1, 1, 1), Motion("t", "c")),
        (View(1, 2, 2), Motion("t", "d")),
        (View(1, 4, 4), Motion("t", "e")),
    ]
コード例 #3
0
def test_find_F():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 5, 5), "F"))
    assert output == [
        (View(1, 4, 4), Motion("F", "d")),
        (View(1, 2, 2), Motion("F", "c")),
        (View(1, 1, 1), Motion("F", "b")),
        (View(1, 0, 0), Motion("F", "a")),
    ]
コード例 #4
0
def test_find_f():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 0, 0), "f"))
    assert output == [
        (View(1, 1, 1), Motion("f", "b")),
        (View(1, 2, 2), Motion("f", "c")),
        (View(1, 3, 3), Motion("f", "d")),
        (View(1, 5, 5), Motion("f", "e")),
    ]
コード例 #5
0
ファイル: dijkstra.py プロジェクト: danth/pathfinder.vim
    def __init__(self, from_view, target_view, min_line, max_line):
        self.from_view = from_view
        self.target_view = target_view
        self.min_line = min_line
        self.max_line = max_line

        self.motion_generators = {
            SimpleMotionGenerator(self),
            FindMotionGenerator(self),
            SearchMotionGenerator(self),
        }

        self._open_queue = heapdict()  # Min-priority queue: Key -> Distance
        self._open_nodes = dict()  # Key -> Node
        self._closed_nodes = set()  # Key

        start_node = Node(self, self.from_view, None)
        self._open_queue[start_node.key] = 0
        self._open_nodes[start_node.key] = start_node
コード例 #6
0
def test_find_T_second_column():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 1, 1), "T"))
    assert len(output) == 0
コード例 #7
0
def test_find_F_first_column():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 0, 0), "F"))
    assert len(output) == 0
コード例 #8
0
def test_find_t_penultimate_column():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 4, 4), "t"))
    assert len(output) == 0
コード例 #9
0
def test_find_f_final_column():
    generator = FindMotionGenerator(None)
    output = list(generator._find(View(1, 5, 5), "f"))
    assert len(output) == 0