def test_count_indents_length_last_line(self): MAT = SourceString('Test100\n test\n more') assert MAT.count_indents_length_last_line(2) == (0, 0) MAT.eat_length(8) assert MAT.count_indents_length_last_line(2) == (0, 0) MAT.eat_length(7) assert MAT.count_indents_length_last_line(2) == (1, 2)
def test_get_char(self): SRC = SourceString('hello world') assert SRC.get_char() == 'h' SRC.eat_length(10) assert SRC.get_char() == 'd' SRC.eat_length(1) assert SRC.eos assert SRC.get_char() == ''
def test_has_space(self): SRC = SourceString('hello world') assert SRC.has_space() == True assert SRC.has_space(11) == True assert SRC.has_space(12) == False SRC.eat_length(11) assert SRC.has_space() == False
def test_spew_length_multiline_peices(self): SRC = SourceString('hello\nworld') SRC.eat_length(11) assert SRC.row == 2 assert SRC.col == 5 assert SRC.get_char() == '' assert SRC.eos SRC.spew_length(5) assert SRC.row == 2 assert SRC.col == 0 assert SRC.get_char() == 'w' assert not SRC.eos SRC.spew_length(6) assert SRC.row == 1 assert SRC.col == 0 assert SRC.get_char() == 'h'
def test_get_string(self): SRC = SourceString('hello world') assert SRC.get_string() == 'hello' SRC.eat_length(5) assert SRC.get_string() == '' SRC.eat_length(1) assert SRC.get_string() == 'world' SRC.eat_length(5) assert SRC.get_string() == '' SRC.eat_length(5) assert SRC.eos