Skip to content
Prev Previous commit
Next Next commit
[mod] updates tests to match splitter's output
  • Loading branch information
ibizaman committed Dec 26, 2014
commit d012f0d6a4c879655ef0a5e6d4cdb87e92a101ca
8 changes: 4 additions & 4 deletions baron/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def group_generator(sequence):

# It's required in a case where I have something like that:
# ['123.123e', '[+-]', '123']
assert re.match(r'^\d+[eE][-+]?\d+$', current) or re.match(r'^\d*.\d*[eE][-+]?\d+$', current)
assert re.match(r'^\d+[eE][-+]?\d+[jJ]?$', current) or re.match(r'^\d*.\d*[eE][-+]?\d+[jJ]?$', current)

if current == "\\" and iterator.show_next() in ('\n', '\r\n'):
current += next(iterator)
Expand All @@ -82,11 +82,11 @@ def group_generator(sequence):
if re.match(r'^\s+$', str(iterator.show_next())):
current += next(iterator)

if (re.match(r'^\d+$', current) and match_on_next(r'^[.eE]$', iterator)) or\
(current == "." and match_on_next(r'^\d+(-\d+)?[jJeE]?$', iterator)):
if (re.match(r'^\d+$', current) and match_on_next(r'^\.$', iterator)) or\
(current == "." and match_on_next(r'^\d+([jJ]|[eE]\d+)?$', iterator)):
current += next(iterator)

while match_on_next(r'^-?\d*[jJeE]?$', iterator) and match_on_next(r'^-?\d*[jJeE]?$', iterator).group():
if match_on_next(r'^\d*[jJ]?$', iterator) and match_on_next(r'^\d*[jJ]?$', iterator).group():
current += next(iterator)

if re.match(r'^\d+\.$', current) and match_on_next(r'^\d*[eE]\d*$', iterator):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ def test_complex():
assert group(['1', '.', '1j']) == ['1.1j']
assert group(['1', '.', '1J']) == ['1.1J']
assert group(['1J']) == ['1J']
assert group(['1', 'e', '-', '1', 'j']) == ['1e-1j']
assert group(['1', 'e', '-1', 'j']) == ['1e-1j']
assert group(['1e', '-', '1j']) == ['1e-1j']


def test_float_exponant():
Expand All @@ -202,4 +201,5 @@ def test_float_exponant():
assert group(['1', '.', 'e', '-', '2']) == ['1.e-2']
assert group(['1', '.', 'e', '2']) == ['1.e2']
assert group(['1', '.', 'e2']) == ['1.e2']
assert group(['.', '3', 'e', '5', '5']) == ['.3e55']
assert group(['.', '3e55']) == ['.3e55']