예제 #1
0
    def test_get_paths_simple_duo(self):
        command_a = self.create(AssignmentCommand, ('a', 1))
        command_b = self.create(AssignmentCommand, ('b', 2), after = command_a)

        command_node = Block().scan(command_a)

        paths = list(command_node.get_paths())

        self.assertIn([command_a, command_b],
                      [[n.command for n in p] for p in paths])
예제 #2
0
    def test_get_paths_simple_branch(self):
        command_c_true = self.create(AssignmentCommand, ('c', 3))
        command_c_false = self.create(AssignmentCommand, ('c', 4))

        command_c = self.create(
            IfCommand,
            (True, command_c_true, command_c_false))

        command_node = Block().scan(command_c)

        paths = list(command_node.get_paths())

        self.assertIn([command_c, command_c_true],
                      [[n.command for n in p] for p in paths])
        self.assertIn([command_c, command_c_false],
                      [[n.command for n in p] for p in paths])