<s> from nose . tools import * <EOL> from vii . Buffer import * <EOL> from vii . Signals import slot <EOL> class Receiver : <EOL> def __init__ ( self ) : <EOL> slot ( "<STR_LIT>" , self ) <EOL> slot ( "<STR_LIT>" , self ) <EOL> slot ( "<STR_LIT>" , self ) <EOL> slot ( "<STR_LIT>" , self ) <EOL> self . seen = { } <EOL> def receive ( self , signal , sender , ** args ) : <EOL> self . seen [ signal ] = args <EOL> class Buffer_Test : <EOL> def fillAndClear ( self , text ) : <EOL> self . buffer . fill ( text ) <EOL> self . signals . clear ( ) <EOL> def setup ( self ) : <EOL> self . receiver = Receiver ( ) <EOL> self . signals = self . receiver . seen <EOL> self . buffer = Buffer ( ) <EOL> def test_init ( self ) : <EOL> assert self . buffer . __class__ == Buffer <EOL> assert Buffer . updatedSignal == "<STR_LIT>" <EOL> assert Buffer . filledSignal == "<STR_LIT>" <EOL> assert Buffer . deletedSignal == "<STR_LIT>" <EOL> assert Buffer . insertedSignal == "<STR_LIT>" <EOL> assert "<STR_LIT>" not in dir ( Buffer ) <EOL> assert self . buffer . lines == [ ] <EOL> assert "<STR_LIT>" in self . signals <EOL> """<STR_LIT>""" <EOL> def test__parse_emptyString ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT>" ) == [ ] <EOL> assert self . buffer . _join ( [ ] ) == "<STR_LIT>" <EOL> def test__parse_nl ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT:\n>" ) == [ "<STR_LIT:\n>" ] <EOL> assert self . buffer . _join ( [ "<STR_LIT:\n>" ] ) == "<STR_LIT:\n>" <EOL> def test__parse_x ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT:x>" ) == [ "<STR_LIT:x>" ] <EOL> assert self . buffer . _join ( [ "<STR_LIT:x>" ] ) == "<STR_LIT:x>" <EOL> def test__parse_xnl ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT>" ) == [ "<STR_LIT>" ] <EOL> def test__parse_xnlx ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT>" ) == [ "<STR_LIT>" , "<STR_LIT:x>" ] <EOL> assert self . buffer . _join ( [ "<STR_LIT>" , "<STR_LIT:x>" ] ) == "<STR_LIT>" <EOL> def test__parse_xnlxnl ( self ) : <EOL> assert self . buffer . _parse ( "<STR_LIT>" ) == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> def test__parse_withEmptyLine ( self ) : <EOL> text = "<STR_LIT>" <EOL> expect = [ "<STR_LIT:\n>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> assert self . buffer . _parse ( text ) == expect <EOL> assert self . buffer . _join ( expect ) == text <EOL> text = "<STR_LIT>" <EOL> expect = [ "<STR_LIT>" , "<STR_LIT:\n>" , "<STR_LIT:\n>" , "<STR_LIT>" ] <EOL> assert self . buffer . _parse ( text ) == expect <EOL> assert self . buffer . _join ( expect ) == text <EOL> text = "<STR_LIT>" <EOL> expect = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:\n>" ] <EOL> assert self . buffer . _parse ( text ) == expect <EOL> assert self . buffer . _join ( expect ) == text <EOL> def test_fill ( self ) : <EOL> self . signals . clear ( ) <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . lines == [ ] <EOL> assert not "<STR_LIT>" in self . signals <EOL> assert not "<STR_LIT>" in self . signals <EOL> self . buffer . fill ( "<STR_LIT:\n>" ) <EOL> assert self . buffer . lines == [ "<STR_LIT:\n>" ] <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . lines == [ "<STR_LIT>" ] <EOL> def test__resolve_range_lines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> range = Range ( ( <NUM_LIT:2> , None ) , ( <NUM_LIT:2> , None ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> range = Range ( ( <NUM_LIT:1> , None ) , ( <NUM_LIT:2> , None ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> range = Range ( ( <NUM_LIT:3> , None ) , ( <NUM_LIT:2> , None ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:3> , <NUM_LIT:4> ) ) <EOL> def test__resolve_range_in_line ( self ) : <EOL> range = Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == range <EOL> range = Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == range <EOL> range = Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> def test__resolve_range_positions ( self ) : <EOL> range = Range ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == range <EOL> range = Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> resolved = self . buffer . _resolveRange ( range ) <EOL> assert resolved == Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> """<STR_LIT>""" <EOL> def test_isEmpty ( self ) : <EOL> assert self . buffer . isEmpty ( ) <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . isEmpty ( ) <EOL> self . buffer . fill ( "<STR_LIT:\n>" ) <EOL> assert not self . buffer . isEmpty ( ) <EOL> def test_characterCount ( self ) : <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . characterCount ( ) == <NUM_LIT:0> <EOL> self . buffer . fill ( "<STR_LIT:\n>" ) <EOL> assert self . buffer . characterCount ( ) == <NUM_LIT:1> <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . characterCount ( ) == <NUM_LIT:2> <EOL> self . buffer . fill ( "<STR_LIT>" ) <EOL> assert self . buffer . characterCount ( ) == <NUM_LIT:2> <EOL> def test_countOfLines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> assert self . buffer . countOfLines ( ) == <NUM_LIT:3> <EOL> def test_lengthOfLine ( self ) : <EOL> "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> assert self . buffer . lengthOfLine ( <NUM_LIT:3> ) == <NUM_LIT:4> <EOL> def test_lastPosition ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> last = self . buffer . lastPosition ( ) <EOL> assert last == Position ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> """<STR_LIT>""" <EOL> def test__checkBufferBounds_validInnerRange ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:1> ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:3> ) <EOL> assert True <EOL> @ raises ( BufferBoundsException ) <EOL> def test__checkBufferBounds_negativeException ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:0> ) <EOL> @ raises ( BufferBoundsException ) <EOL> def test__checkBufferBounds_positiveException ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:4> ) <EOL> def test__checkBufferBounds_plus1_validInnerRange ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:4> , plus = <NUM_LIT:1> ) <EOL> assert True <EOL> @ raises ( BufferBoundsException ) <EOL> def test__checkBufferBounds_plus1_positiveException ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . _checkBufferBounds ( <NUM_LIT:5> , plus = <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> def test_copy_from_empty_buffer ( self ) : <EOL> assert self . buffer . copy ( Range ( <NUM_LIT:1> , <NUM_LIT:10> ) ) == "<STR_LIT>" <EOL> def test_copy_lines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:1> , <NUM_LIT:6> ) ) <EOL> assert result == text <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:6> , <NUM_LIT:1> ) ) <EOL> assert result == text <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:2> , <NUM_LIT:5> ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( <NUM_LIT:5> , <NUM_LIT:2> ) ) <EOL> assert result == "<STR_LIT>" <EOL> def test_copy_from_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ) ) <EOL> assert result == "<STR_LIT:1>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:4> ) , ( <NUM_LIT:2> , <NUM_LIT:4> ) ) ) <EOL> assert result == "<STR_LIT:4>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) ) ) <EOL> assert result == "<STR_LIT:\n>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> assert result == "<STR_LIT:2>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:4> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:4> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> def test_copy_from_range ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:6> , <NUM_LIT:7> ) ) ) <EOL> assert result == text <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:1> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:4> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:5> , <NUM_LIT:1> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> result = self . buffer . copy ( Range ( ( <NUM_LIT:2> , <NUM_LIT:3> ) , ( <NUM_LIT:3> , <NUM_LIT:1> ) ) ) <EOL> assert result == "<STR_LIT>" <EOL> """<STR_LIT>""" <EOL> def deleted ( self , key ) : <EOL> return self . signals [ "<STR_LIT>" ] [ key ] <EOL> def test_delete_from_empty_buffer_does_nothing ( self ) : <EOL> assert self . buffer . lines == [ ] <EOL> self . buffer . delete ( Range ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> assert self . buffer . lines == [ ] <EOL> """<STR_LIT>""" <EOL> def test_delete_first_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> assert "<STR_LIT>" in self . signals <EOL> def test_delete_intermediate_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_delete_last_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:6> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> def test_delete_muliple_lines_at_start ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_delete_muliple_lines_inversed ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:5> , <NUM_LIT:2> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:6> , <NUM_LIT:1> ) <EOL> def test_delete_muliple_lines_at_end ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:5> , <NUM_LIT:6> ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> def test_delete_all_lines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:1> , <NUM_LIT:6> ) ) <EOL> assert str ( self . buffer ) == "<STR_LIT>" <EOL> assert self . buffer . lines == [ ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> def test_delete_all_lines_inversed ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( <NUM_LIT:6> , <NUM_LIT:1> ) ) <EOL> assert str ( self . buffer ) == "<STR_LIT>" <EOL> assert self . buffer . lines == [ ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> def test_delete_first_sign_in_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Position ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> assert self . buffer . lines == [ "<STR_LIT:\n>" , "<STR_LIT>" ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> def test_delete_last_sign_in_line ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> assert self . buffer . lines == [ "<STR_LIT>" ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> def test_delete_in_line_without_bounds ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:4> ) ) ) <EOL> assert self . buffer . lines == [ "<STR_LIT>" , "<STR_LIT:\n>" ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> @ raises ( LastLinebreakLostExecption ) <EOL> def test_delete_last_singn_in_last_line_excepts ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Position ( <NUM_LIT:2> , <NUM_LIT:5> ) ) <EOL> @ raises ( LastLinebreakLostExecption ) <EOL> def test_delete_last_singns_in_last_line_excepts ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) ) ) <EOL> """<STR_LIT>""" <EOL> def test_delete_from_range_of_end_of_lines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:3> ) , ( <NUM_LIT:5> , <NUM_LIT:6> ) ) ) <EOL> assert self . buffer . lines == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:6> , <NUM_LIT:1> ) <EOL> def test_delete_from_range_amidst_lines ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:2> ) ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> def test_delete_from_range_amidst_lines_inversed ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:3> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> def test_delete_from_range_amidst_to_end ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:5> , <NUM_LIT:6> ) ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:6> , <NUM_LIT:1> ) <EOL> def test_delete_from_range_end_to_amidst ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . buffer . fill ( text ) <EOL> self . buffer . delete ( Range ( ( <NUM_LIT:2> , <NUM_LIT:3> ) , ( <NUM_LIT:5> , <NUM_LIT:2> ) ) ) <EOL> assert self . buffer . lines == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert self . deleted ( "<STR_LIT>" ) == Position ( <NUM_LIT:5> , <NUM_LIT:3> ) <EOL> """<STR_LIT>""" <EOL> def inserted ( self , key ) : <EOL> return self . signals [ "<STR_LIT>" ] [ key ] <EOL> def test_insert_lines_when_empty ( self ) : <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . buffer . insert ( Position ( <NUM_LIT:1> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert "<STR_LIT>" in self . signals <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> def test_insert_lines_between ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> def test_insert_lines_on_top ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:1> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_insert_lines_at_bottom ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:4> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> @ raises ( LastLinebreakLostExecption ) <EOL> def test_insert_line_into_empty_buffer_without_nl ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT:abc>" <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:1> , <NUM_LIT:1> ) , text ) <EOL> @ raises ( LastLinebreakLostExecption ) <EOL> def test_insert_line_at_bottom_without_nl ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT:abc>" <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , text ) <EOL> @ raises ( LastLinebreakLostExecption ) <EOL> def test_insert_lines_at_bottom_without_nl ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:4> , <NUM_LIT:1> ) , text ) <EOL> def test_insert_single_line ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , "<STR_LIT>" ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , "<STR_LIT:\n>" ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_insert_empty_lines ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:1> , <NUM_LIT:1> ) , text ) <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:4> , <NUM_LIT:1> ) , text ) <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:6> , <NUM_LIT:1> ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:7> , <NUM_LIT:1> ) , text ) <EOL> expect = [ '<STR_LIT:\n>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT:\n>' ] <EOL> assert self . buffer . lines == expect <EOL> def test_insert_empty_string ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = "<STR_LIT>" <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert str ( self . buffer ) == expect <EOL> assert not "<STR_LIT>" in self . signals <EOL> def test_insert_simple_string ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> def test_insert_at_begin_of_line ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> def test_insert_newline_at_begin_of_line ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT:\n>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:1> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_insert_at_end_of_line ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:3> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> def test_insert_newline_at_end_of_line ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT:\n>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:3> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_insert_newline ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT:\n>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> def test_insert_surrounding_newlines ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> def test_insert_without_body ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> def test_insert_with_body ( self ) : <EOL> prefill = "<STR_LIT>" <EOL> text = "<STR_LIT>" <EOL> expect = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fillAndClear ( prefill ) <EOL> self . buffer . insert ( Position ( <NUM_LIT:2> , <NUM_LIT:2> ) , text ) <EOL> assert self . buffer . lines == expect <EOL> assert self . inserted ( "<STR_LIT>" ) == Position ( <NUM_LIT:4> , <NUM_LIT:3> ) </s>
