| 2678 | |
| 2679 | @unittest.skipIf(multiprocessing is None, 'test requires multiprocessing') |
| 2680 | def test_regression_gh94675(self): |
| 2681 | pattern = re.compile(r'(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*' |
| 2682 | r'((/[^/\[\n]*(([^\n]|(\[\n]*(]*)*\]))' |
| 2683 | r'[^/\[]*)*/))((((//[^\n]*)?[\n])' |
| 2684 | r'([\000-\040]|(/\*[^*]*\*+' |
| 2685 | r'([^/*]\*+)*/))*)+(?=[^\000-\040);\]}]))') |
| 2686 | input_js = '''a(function() { |
| 2687 | /////////////////////////////////////////////////////////////////// |
| 2688 | });''' |
| 2689 | p = multiprocessing.Process(target=pattern.sub, args=('', input_js)) |
| 2690 | p.start() |
| 2691 | p.join(SHORT_TIMEOUT) |
| 2692 | try: |
| 2693 | self.assertFalse(p.is_alive(), 'pattern.sub() timed out') |
| 2694 | finally: |
| 2695 | if p.is_alive(): |
| 2696 | p.terminate() |
| 2697 | p.join() |
| 2698 | |
| 2699 | def test_fail(self): |
| 2700 | self.assertEqual(re.search(r'12(?!)|3', '123')[0], '3') |