2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 21bdd9a3 authored by di68kap's avatar di68kap
Browse files

- bugfix: preprocess.py

parent 8473cf32
......@@ -185,7 +185,7 @@ def tokenized_to_original_mapping(tokenized_source: str) -> SourceMap:
positions, offsets = [0], [0]
o = 0
i = tokenized_source.find(BEGIN_TOKEN)
e = -1
e = -2
while i >= 0:
d = tokenized_source.find(TOKEN_DELIMITER, i)
e = tokenized_source.find(END_TOKEN, i)
......
......@@ -70,6 +70,16 @@ class TestSourceMapping:
assert offsets[-1] >= offsets[-2]
assert self.tokenized.find('AND') == self.code.find('AND') + len('CONJUNCTION') + 2
def test_bondary_cases(self):
# position at the end of the file
source = " "
srcmap = tokenized_to_original_mapping(source)
pos = source_map(1, srcmap)
# empty file
source =""
srcmap = tokenized_to_original_mapping(source)
pos = source_map(0, srcmap)
class TestTokenParsing:
def preprocess_indentation(self, src: str) -> str:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment