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_spew_length(self): SRC = SourceString('hello world') SRC.eat_string('hello world') assert SRC.eos SRC.spew_length(1) assert SRC.get_char() == 'd' SRC.spew_length(10) assert SRC.get_char() == 'h' SRC.spew_length(3) assert SRC.get_char() == 'h'
def test_skip_whitespace(self): MAT = SourceString(' \tTest100') MAT2 = SourceString(' \nTest100') MAT.skip_whitespace() assert MAT.get_char() == 'T' MAT2.skip_whitespace() assert MAT2.get_char() == '\n' MAT2.skip_whitespace(1) assert MAT2.get_char() == 'T'
def test_eat_line(self): SRC = SourceString('hello\nworld') SRC.eat_line() assert SRC.row == 2 assert SRC.col == 0 assert SRC.get_char() == 'w' SRC.eat_line() assert SRC.row == 2 assert SRC.col == 5 assert SRC.get_char() == ''
def test_eat_string_multiline_chunk(self): SRC = SourceString('hello\nworld') SRC.eat_string('hello\nworld') assert SRC.row == 2 assert SRC.col == 5 assert SRC.get_char() == ''
def test_eat_string_multiline_peices(self): SRC = SourceString('hello\nworld') SRC.eat_string(SRC.get_length(5)) assert SRC.row == 1 assert SRC.col == 5 assert SRC.get_char() == '\n' SRC.eat_string(SRC.get_char()) assert SRC.row == 2 assert SRC.col == 0 SRC.eat_string(SRC.get_length(5)) assert SRC.row == 2 assert SRC.col == 5 assert SRC.get_char() == ''
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'