BCI-assembler/assembler/test/test_010_filecontext.py

25 lines
547 B
Python
Raw Permalink Normal View History

2018-10-09 09:44:00 +00:00
from io import StringIO
from assembler.context import FileContext
def test_getc_ungetc():
data = StringIO("abc\ndefg")
context = FileContext(data)
assert context.getc() == "a"
assert context.getc() == "b"
assert context._line == 0
assert context._column == 2
assert context.getc() == "c"
assert context.getc() == "\n"
assert context.getc() == "d"
assert context._line == 1
assert context._column == 1
context.ungetc("d")
context.ungetc("\n")
assert context._column == 3
assert context._line == 0
assert context.getc() == "\n"