aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2022-08-25 12:16:10 +0100
committerdirkf <fieldhouse@gmx.net>2022-08-25 12:16:10 +0100
commitd619dd712f63aab1964f8fdde9ceea514a5e581d (patch)
tree31902c8248457622a7c21c3bbd31248316764397 /test
parent573b13410e5c2f939676116e2700ec8efd9cf97b (diff)
downloadyoutube-dl-d619dd712f63aab1964f8fdde9ceea514a5e581d.tar.xz
[jsinterp] Fix bug in operator precedence
* from https://github.com/yt-dlp/yt-dlp/commit/164b03c4864b0d44cfee5e7702f7c2317164a6cf * added tests
Diffstat (limited to 'test')
-rw-r--r--test/test_jsinterp.py25
-rw-r--r--test/test_youtube_signature.py4
2 files changed, 29 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py
index 96786a84c..0a97bdbc4 100644
--- a/test/test_jsinterp.py
+++ b/test/test_jsinterp.py
@@ -192,6 +192,31 @@ class TestJSInterpreter(unittest.TestCase):
''')
self.assertEqual(jsi.call_function('x'), 10)
+ def test_catch(self):
+ jsi = JSInterpreter('''
+ function x() { try{throw 10} catch(e){return 5} }
+ ''')
+ self.assertEqual(jsi.call_function('x'), 5)
+
+ @unittest.expectedFailure
+ def test_finally(self):
+ jsi = JSInterpreter('''
+ function x() { try{throw 10} finally {return 42} }
+ ''')
+ self.assertEqual(jsi.call_function('x'), 42)
+ jsi = JSInterpreter('''
+ function x() { try{throw 10} catch(e){return 5} finally {return 42} }
+ ''')
+ self.assertEqual(jsi.call_function('x'), 42)
+
+ def test_nested_try(self):
+ jsi = JSInterpreter('''
+ function x() {try {
+ try{throw 10} finally {throw 42}
+ } catch(e){return 5} }
+ ''')
+ self.assertEqual(jsi.call_function('x'), 5)
+
def test_for_loop_continue(self):
jsi = JSInterpreter('''
function x() { a=0; for (i=0; i-10; i++) { continue; a++ } return a }
diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py
index 327d4c40d..4bb0a30b0 100644
--- a/test/test_youtube_signature.py
+++ b/test/test_youtube_signature.py
@@ -111,6 +111,10 @@ _NSIG_TESTS = [
'https://www.youtube.com/s/player/1f7d5369/player_ias.vflset/en_US/base.js',
'batNX7sYqIJdkJ', 'IhOkL_zxbkOZBw',
),
+ (
+ 'https://www.youtube.com/s/player/dc0c6770/player_ias.vflset/en_US/base.js',
+ '5EHDMgYLV6HPGk_Mu-kk', 'n9lUJLHbxUI0GQ',
+ ),
]