aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_jsinterp.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-04-27 07:42:17 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-04-27 07:52:09 +0530
commit7cf51f21916292cd80bdeceb37489f5322f166dd (patch)
tree39a3449d1e948a31c3d2a857cb885b8946a1f248 /test/test_jsinterp.py
parent170605840ea9d5ad75da6576485ea7d125b428ee (diff)
downloadhypervideo-pre-7cf51f21916292cd80bdeceb37489f5322f166dd.tar.lz
hypervideo-pre-7cf51f21916292cd80bdeceb37489f5322f166dd.tar.xz
hypervideo-pre-7cf51f21916292cd80bdeceb37489f5322f166dd.zip
[jsinterp] Handle negative numbers better
Closes #6131
Diffstat (limited to 'test/test_jsinterp.py')
-rw-r--r--test/test_jsinterp.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py
index e090dc791..3283657d7 100644
--- a/test/test_jsinterp.py
+++ b/test/test_jsinterp.py
@@ -445,6 +445,22 @@ class TestJSInterpreter(unittest.TestCase):
jsi = JSInterpreter('function x(){return 1236566549 << 5}')
self.assertEqual(jsi.call_function('x'), 915423904)
+ def test_negative(self):
+ jsi = JSInterpreter("function f(){return 2 * -2.0;}")
+ self.assertEqual(jsi.call_function('f'), -4)
+
+ jsi = JSInterpreter('function f(){return 2 - - -2;}')
+ self.assertEqual(jsi.call_function('f'), 0)
+
+ jsi = JSInterpreter('function f(){return 2 - - - -2;}')
+ self.assertEqual(jsi.call_function('f'), 4)
+
+ jsi = JSInterpreter('function f(){return 2 - + + - -2;}')
+ self.assertEqual(jsi.call_function('f'), 0)
+
+ jsi = JSInterpreter('function f(){return 2 + - + - -2;}')
+ self.assertEqual(jsi.call_function('f'), 0)
+
if __name__ == '__main__':
unittest.main()