fix at_beginning

This commit is contained in:
Kangzhi Shi
2021-01-21 16:14:23 +02:00
parent 40b68fbea7
commit df42fd913f
3 changed files with 5 additions and 6 deletions

View File

@@ -88,8 +88,6 @@ class ReTests(unittest.TestCase):
int_value = int(matchobj.group(0))
return str(int_value + 1)
# TODO: RUSTPYTHON
# @unittest.expectedFailure
def test_basic_re_sub(self):
self.assertTypedEqual(re.sub('y', 'a', 'xyz'), 'xaz')
self.assertTypedEqual(re.sub('y', S('a'), S('xyz')), 'xaz')
@@ -1661,8 +1659,6 @@ class ReTests(unittest.TestCase):
self.checkPatternError(r'(?i+', 'missing -, : or )', 3)
self.checkPatternError(r'(?iz', 'unknown flag', 3)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_bug_6509(self):
# Replacement strings of both types must parse properly.
# all strings

View File

@@ -59,4 +59,6 @@ assert re.compile('(a)(bc)').match('abc')[1] == 'a'
assert re.compile('a(b)(?P<a>c)d').match('abcd').groupdict() == {'a': 'c'}
# test op branch
assert re.compile(r'((?=\d|\.\d)(?P<int>\d*)|a)', re.DEBUG).match('123.2132').group() == '123'
assert re.compile(r'((?=\d|\.\d)(?P<int>\d*)|a)').match('123.2132').group() == '123'
assert re.sub(r'^\s*', 'X', 'test') == 'Xtest'

View File

@@ -274,7 +274,8 @@ trait MatchContextDrive {
self.state().pattern_codes.len() - self.ctx().code_position
}
fn at_beginning(&self) -> bool {
self.ctx().string_position == self.state().start
// self.ctx().string_position == self.state().start
self.ctx().string_position == 0
}
fn at_end(&self) -> bool {
self.ctx().string_position == self.state().end