diff options
author | Tim Hatch <tim@timhatch.com> | 2014-10-10 07:27:03 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-10-10 07:27:03 -0700 |
commit | ceee3a3ad356dc8ab0dce1a67441a2d10b7738be (patch) | |
tree | f45aeecb834f50057291989dc4ff7e41313c7df6 /tests/test_regexopt.py | |
parent | ececf9767b5cc2a5ae633f05e0ad8e09e1d3ace2 (diff) | |
download | pygments-ceee3a3ad356dc8ab0dce1a67441a2d10b7738be.tar.gz |
Add aditional tests for regex optimization.
Diffstat (limited to 'tests/test_regexopt.py')
-rw-r--r-- | tests/test_regexopt.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_regexopt.py b/tests/test_regexopt.py index f62a57ef..66f7c609 100644 --- a/tests/test_regexopt.py +++ b/tests/test_regexopt.py @@ -50,3 +50,19 @@ class RegexOptTestCase(unittest.TestCase): self.assertTrue(rex.match(w)) for w in no_match: self.assertFalse(rex.match(w)) + + def test_prefix(self): + opt = regex_opt(('a', 'b'), prefix=r':{1,2}') + print(opt) + rex = re.compile(opt) + self.assertFalse(rex.match('a')) + self.assertTrue(rex.match('::a')) + self.assertFalse(rex.match(':::')) # fullmatch + + def test_suffix(self): + opt = regex_opt(('a', 'b'), suffix=r':{1,2}') + print(opt) + rex = re.compile(opt) + self.assertFalse(rex.match('a')) + self.assertTrue(rex.match('a::')) + self.assertFalse(rex.match(':::')) # fullmatch |