<s> from nose . plugins . skip import SkipTest <EOL> from vii . Cursor import * <EOL> from vii . Signals import * <EOL> class BufferMock : <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> def isEmpty ( self ) : <EOL> return len ( self . text ) == <NUM_LIT:0> <EOL> def lengthOfLine ( self , index ) : <EOL> return len ( self . text [ index - <NUM_LIT:1> ] ) <EOL> def copyLines ( self , index , count ) : <EOL> return self . text [ index - <NUM_LIT:1> ] <EOL> def countOfLines ( self ) : <EOL> return len ( self . text ) <EOL> class MotionsMock : <EOL> def gotoPositionStrict ( self , position ) : <EOL> self . targetPosition = position <EOL> if position == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) : <EOL> "<STR_LIT>" <EOL> return Range ( ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> else : <EOL> "<STR_LIT>" <EOL> return Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> class Cursor_Test : <EOL> def setup ( self ) : <EOL> self . buffer = BufferMock ( ) <EOL> self . motions = MotionsMock ( ) <EOL> self . fixture = Cursor ( ) <EOL> self . fixture . x = <NUM_LIT:1> <EOL> self . fixture . y = <NUM_LIT:1> <EOL> self . fixture . buffer = self . buffer <EOL> self . fixture . motions = self . motions <EOL> slot ( "<STR_LIT>" , self ) <EOL> self . cursorMoved = False <EOL> def receive ( self , signal , sender ) : <EOL> if signal == "<STR_LIT>" : <EOL> if sender == self . fixture : <EOL> self . cursorMoved = True <EOL> def test_init ( self ) : <EOL> assert self . fixture . __class__ == Cursor <EOL> assert self . fixture . buffer == self . buffer <EOL> assert self . fixture . motions == self . motions <EOL> assert self . fixture . x == <NUM_LIT:1> <EOL> assert self . fixture . y == <NUM_LIT:1> <EOL> def test_update ( self ) : <EOL> self . fixture . updated ( ) <EOL> assert self . cursorMoved <EOL> def test_position ( self ) : <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert not self . cursorMoved <EOL> self . fixture . position ( Position ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert self . cursorMoved <EOL> """<STR_LIT>""" <EOL> def test_insert_vertically_after_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> startPosition = Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> afterPosition = Position ( <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert not self . cursorMoved <EOL> def test_insert_horizontally_after_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> startPosition = Position ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> afterPosition = Position ( <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert not self . cursorMoved <EOL> def test_insert_vertically_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> self . fixture . position ( Position ( <NUM_LIT:3> , <NUM_LIT:2> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> startPosition = Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> afterPosition = Position ( <NUM_LIT:4> , <NUM_LIT:1> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:5> , <NUM_LIT:2> ) <EOL> assert self . cursorMoved <EOL> def test_insert_horizontally_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> self . fixture . position ( Position ( <NUM_LIT:2> , <NUM_LIT:4> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> startPosition = Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:5> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:2> , <NUM_LIT:7> ) <EOL> assert self . cursorMoved <EOL> def test_insert_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> self . fixture . position ( Position ( <NUM_LIT:2> , <NUM_LIT:8> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> startPosition = Position ( <NUM_LIT:2> , <NUM_LIT:6> ) , <EOL> afterPosition = Position ( <NUM_LIT:4> , <NUM_LIT:2> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:4> , <NUM_LIT:4> ) <EOL> assert self . cursorMoved <EOL> """<STR_LIT>""" <EOL> def test_delete_vertically_after_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> startPosition = Position ( <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert not self . cursorMoved <EOL> def test_delete_horizontally_after_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> startPosition = Position ( <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert not self . cursorMoved <EOL> def test_delete_vertically_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> self . fixture . position ( Position ( <NUM_LIT:5> , <NUM_LIT:2> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> startPosition = Position ( <NUM_LIT:4> , <NUM_LIT:1> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> assert self . cursorMoved <EOL> def test_delete_horizontally_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> self . fixture . position ( Position ( <NUM_LIT:2> , <NUM_LIT:7> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , <EOL> startPosition = Position ( <NUM_LIT:2> , <NUM_LIT:5> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> assert self . cursorMoved <EOL> def test_delete_before_cursor ( self ) : <EOL> """<STR_LIT>""" <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> self . fixture . position ( Position ( <NUM_LIT:4> , <NUM_LIT:4> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:6> ) , <EOL> startPosition = Position ( <NUM_LIT:4> , <NUM_LIT:2> ) ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:2> , <NUM_LIT:8> ) <EOL> assert self . cursorMoved <EOL> def test_delete_around_cursor ( self ) : <EOL> "<STR_LIT>" <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> self . fixture . position ( Position ( <NUM_LIT:3> , <NUM_LIT:2> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:2> , <NUM_LIT:6> ) , <EOL> startPosition = Position ( <NUM_LIT:4> , <NUM_LIT:5> ) ) <EOL> assert self . motions . targetPosition == Position ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> assert self . cursorMoved <EOL> def test_delete_last_lines_with_cursor ( self ) : <EOL> "<STR_LIT>" <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> self . fixture . position ( Position ( <NUM_LIT:5> , <NUM_LIT:2> ) ) <EOL> text = "<STR_LIT>" . splitlines ( ) <EOL> self . buffer . text = text <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:4> , <NUM_LIT:1> ) , <EOL> startPosition = Position ( <NUM_LIT:5> , <NUM_LIT:3> ) ) <EOL> assert self . motions . targetPosition == Position ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> assert self . cursorMoved <EOL> def test_delete_all_lines ( self ) : <EOL> "<STR_LIT>" <EOL> self . fixture . position ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> self . buffer . text = [ ] <EOL> signal ( "<STR_LIT>" , self . buffer , <EOL> afterPosition = Position ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> startPosition = Position ( <NUM_LIT:4> , <NUM_LIT:1> ) ) <EOL> assert self . motions . targetPosition == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . fixture . position ( ) == Position ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> assert self . cursorMoved </s>
