diff options
author | Elyse <26639800+elyse0@users.noreply.github.com> | 2022-08-19 00:30:04 -0500 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-08-31 21:01:22 +0530 |
commit | f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa (patch) | |
tree | 697fefb123fb9afeb53804d7b7e4d6bc674f7daf /test/test_jsinterp.py | |
parent | bfbecd1174a9e2ee08117352c26e664d36f1cc17 (diff) | |
download | hypervideo-pre-f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa.tar.lz hypervideo-pre-f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa.tar.xz hypervideo-pre-f26af78a8ac11d9d617ed31ea5282cfaa5bcbcfa.zip |
[jsinterp] Add `charcodeAt` and bitwise overflow (#4706)
Authored by: elyse0
Diffstat (limited to 'test/test_jsinterp.py')
-rw-r--r-- | test/test_jsinterp.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 778607fb2..4b6e22bac 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -352,6 +352,22 @@ class TestJSInterpreter(unittest.TestCase): ''') self.assertEqual(jsi.call_function('x').flags & re.I, re.I) + def test_char_code_at(self): + jsi = JSInterpreter('function x(i){return "test".charCodeAt(i)}') + self.assertEqual(jsi.call_function('x', 0), 116) + self.assertEqual(jsi.call_function('x', 1), 101) + self.assertEqual(jsi.call_function('x', 2), 115) + self.assertEqual(jsi.call_function('x', 3), 116) + self.assertEqual(jsi.call_function('x', 4), None) + self.assertEqual(jsi.call_function('x', 'not_a_number'), 116) + + def test_bitwise_operators_overflow(self): + jsi = JSInterpreter('function x(){return -524999584 << 5}') + self.assertEqual(jsi.call_function('x'), 379882496) + + jsi = JSInterpreter('function x(){return 1236566549 << 5}') + self.assertEqual(jsi.call_function('x'), 915423904) + if __name__ == '__main__': unittest.main() |