diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-02-01 09:39:49 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-02-01 09:40:16 +0530 |
commit | 8b008d62544b82e24a0ba36c30e8e51855d93419 (patch) | |
tree | 8262dfc4a1f3757b2ddb55d8c22e415449ea90e3 /test | |
parent | 83c4970e52839ce8761ec61bd19d549aed7d7920 (diff) | |
download | hypervideo-pre-8b008d62544b82e24a0ba36c30e8e51855d93419.tar.lz hypervideo-pre-8b008d62544b82e24a0ba36c30e8e51855d93419.tar.xz hypervideo-pre-8b008d62544b82e24a0ba36c30e8e51855d93419.zip |
[jsinterp] Support `if` statements
Closes #6131
Diffstat (limited to 'test')
-rw-r--r-- | test/test_jsinterp.py | 32 | ||||
-rw-r--r-- | test/test_youtube_signature.py | 4 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 3c4391c4a..e090dc791 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -155,6 +155,38 @@ class TestJSInterpreter(unittest.TestCase): self.assertEqual(jsi.call_function('z'), 5) self.assertEqual(jsi.call_function('y'), 2) + def test_if(self): + jsi = JSInterpreter(''' + function x() { + let a = 9; + if (0==0) {a++} + return a + }''') + self.assertEqual(jsi.call_function('x'), 10) + + jsi = JSInterpreter(''' + function x() { + if (0==0) {return 10} + }''') + self.assertEqual(jsi.call_function('x'), 10) + + jsi = JSInterpreter(''' + function x() { + if (0!=0) {return 1} + else {return 10} + }''') + self.assertEqual(jsi.call_function('x'), 10) + + """ # Unsupported + jsi = JSInterpreter(''' + function x() { + if (0!=0) {return 1} + else if (1==0) {return 2} + else {return 10} + }''') + self.assertEqual(jsi.call_function('x'), 10) + """ + def test_for_loop(self): jsi = JSInterpreter(''' function x() { a=0; for (i=0; i-10; i++) {a++} return a } diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index 6d753fbf0..3203538bb 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -134,6 +134,10 @@ _NSIG_TESTS = [ 'https://www.youtube.com/s/player/7a062b77/player_ias.vflset/en_US/base.js', 'NRcE3y3mVtm_cV-W', 'VbsCYUATvqlt5w', ), + ( + 'https://www.youtube.com/s/player/dac945fd/player_ias.vflset/en_US/base.js', + 'o8BkRxXhuYsBCWi6RplPdP', '3Lx32v_hmzTm6A', + ), ] |