about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2023-04-21 14:04:30 +0100
committerdirkf <fieldhouse@gmx.net>2023-04-21 14:04:30 +0100
commit211cbfd5d46025a8e4d8f9f3d424aaada4698974 (patch)
treebc5e22be3fe98643d3c0c14ac3394782e9ba180f /test
parent26035bde46c0acc30dc053618451d9aeca4b7709 (diff)
downloadyoutube-dl-211cbfd5d46025a8e4d8f9f3d424aaada4698974.tar.gz
youtube-dl-211cbfd5d46025a8e4d8f9f3d424aaada4698974.tar.xz
youtube-dl-211cbfd5d46025a8e4d8f9f3d424aaada4698974.zip
[jsinterp] Minimally handle arithmetic operator precedence
Resolves #32066
Diffstat (limited to 'test')
-rw-r--r--test/test_jsinterp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py
index 5d129433d..e121358d7 100644
--- a/test/test_jsinterp.py
+++ b/test/test_jsinterp.py
@@ -505,6 +505,17 @@ class TestJSInterpreter(unittest.TestCase):
         jsi = JSInterpreter('function x(){return 1236566549 << 5}')
         self.assertEqual(jsi.call_function('x'), 915423904)
 
+    def test_32066(self):
+        jsi = JSInterpreter("function x(){return Math.pow(3, 5) + new Date('1970-01-01T08:01:42.000+08:00') / 1000 * -239 - -24205;}")
+        self.assertEqual(jsi.call_function('x'), 70)
+
+    def test_unary_operators(self):
+        jsi = JSInterpreter('function f(){return 2  -  - - 2;}')
+        self.assertEqual(jsi.call_function('f'), 0)
+        # fails
+        # jsi = JSInterpreter('function f(){return 2 + - + - - 2;}')
+        # self.assertEqual(jsi.call_function('f'), 0)
+
     """ # fails so far
     def test_packed(self):
         jsi = JSInterpreter('''function x(p,a,c,k,e,d){while(c--)if(k[c])p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c]);return p}''')