25 lines
547 B
Python
25 lines
547 B
Python
|
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"
|