[jsinterp] Fix escape in regex

This commit is contained in:
pukkandan 2022-09-01 13:14:04 +05:30
parent b505e8517a
commit 05deb747bb
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
4 changed files with 16 additions and 6 deletions

View file

@ -352,6 +352,11 @@ class TestJSInterpreter(unittest.TestCase):
''')
self.assertEqual(jsi.call_function('x').flags & re.I, re.I)
jsi = JSInterpreter('''
function x() { let a=/,][}",],()}(\[)/; return a; }
''')
self.assertEqual(jsi.call_function('x').pattern, r',][}",],()}(\[)')
def test_char_code_at(self):
jsi = JSInterpreter('function x(i){return "test".charCodeAt(i)}')
self.assertEqual(jsi.call_function('x', 0), 116)