Example #1
0
def test_caret_move_behind_top_border():
    lines = [['>', 'v'], ['<', '^']]
    fld = Field(2, 2, lines)
    stk = Stack()
    crt = Caret(stk, fld)
    crt.set_direction(Up)
    crt.move(fld)
    assert crt.direction == Up
    assert crt.pos == Vec(0, 1)
Example #2
0
def test_caret_move():
    lines = [['>', 'v'], ['<', '^']]
    fld = Field(2, 2, lines)
    stk = Stack()
    crt = Caret(stk, fld)
    crt.set_direction(Right)
    crt.move(fld)
    crt.read_instruction(fld)
    assert crt.direction == Right
    assert crt.current_instruction == 'v'
Example #3
0
def test_caret_changes_direction():
    lines = [['>', 'v'], ['<', '^']]
    fld = Field(2, 2, lines)
    stk = Stack()
    crt = Caret(stk, fld)
    crt.set_direction(Down)
    assert crt.direction == Down
    crt.set_direction(Left)
    assert crt.direction == Left
    crt.set_direction(Right)
    assert crt.direction == Right
    crt.set_direction(Up)
    assert crt.direction == Up