Ejemplo n.º 1
0
    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'
Ejemplo n.º 2
0
    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'