Пример #1
0
        with and_.the_rover_should_wrap_from_the_left_edge:
            rover.orders = 'lffff'
            rover.run_orders()
            print(rover.position)
            the(is_same_dictionary(rover.position, {'x': MAP_SIZE, 'y': MAP_SIZE})).should.be(True)

        with and_.the_rover_should_wrap_from_the_right_edge:
            rover.orders = 'rrf'
            rover.run_orders()
            print(rover.position)
            the(is_same_dictionary(rover.position, {'x': -MAP_SIZE, 'y': MAP_SIZE})).should.be(True)

    with when.supplied_with_obstacles:
        obstacles = ({'x': 1, 'y': 1}, {'x': -1, 'y': 2}, {'x': -2, 'y': -2}, {'x': -2, 'y': -MAP_SIZE})
        navigator.obstacles = obstacles
        rover = Rover(starting_point, initial_direction, navigator)

        with then.the_rover_should_avoid_them:
            with and_.the_rover_goes_to_the_E:
                rover.orders = 'frfff'
                rover.run_orders()
                print(rover.position)
                the(rover.position['x']).should.be(0)
                the(rover.position['y']).should.be(1)
                the(is_same_dictionary(rover.position['obstacle'], {'x': 1, 'y': 1})).should.be(True)
                the(rover.orientation).should.be('E')

            with and_.the_rover_goes_to_the_W:
                rover.orders = 'lflfff'
                rover.run_orders()