diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-11-03 16:25:48 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-11-03 16:35:08 +0530 |
commit | a1fc7ca0743c8df06416e68ee74b64e07dfe7135 (patch) | |
tree | 785213545fa8858d2fd3efc6f6d8e90980fbdf14 /test | |
parent | c588b602d34f005dc018ae004281226741414192 (diff) | |
download | hypervideo-pre-a1fc7ca0743c8df06416e68ee74b64e07dfe7135.tar.lz hypervideo-pre-a1fc7ca0743c8df06416e68ee74b64e07dfe7135.tar.xz hypervideo-pre-a1fc7ca0743c8df06416e68ee74b64e07dfe7135.zip |
[jsinterp] Handle default in switch better
Diffstat (limited to 'test')
-rw-r--r-- | test/test_jsinterp.py | 15 | ||||
-rw-r--r-- | test/test_youtube_signature.py | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 380e52c33..e230b045f 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -132,6 +132,21 @@ class TestJSInterpreter(unittest.TestCase): self.assertEqual(jsi.call_function('x', 3), 6) self.assertEqual(jsi.call_function('x', 5), 0) + def test_switch_default(self): + jsi = JSInterpreter(''' + function x(f) { switch(f){ + case 2: f+=2; + default: f-=1; + case 5: + case 6: f+=6; + case 0: break; + case 1: f+=1; + } return f } + ''') + self.assertEqual(jsi.call_function('x', 1), 2) + self.assertEqual(jsi.call_function('x', 5), 11) + self.assertEqual(jsi.call_function('x', 9), 14) + def test_try(self): jsi = JSInterpreter(''' function x() { try{return 10} catch(e){return 5} } diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index f40a06952..60d8eabf5 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -69,7 +69,11 @@ _NSIG_TESTS = [ ( 'https://www.youtube.com/s/player/9216d1f7/player_ias.vflset/en_US/base.js', 'SLp9F5bwjAdhE9F-', 'gWnb9IK2DJ8Q1w', - ), # TODO: Add more tests + ), + ( + 'https://www.youtube.com/s/player/f8cb7a3b/player_ias.vflset/en_US/base.js', + 'oBo2h5euWy6osrUt', 'ivXHpm7qJjJN', + ), ] |