diff options
author | dirkf <fieldhouse@gmx.net> | 2022-08-25 12:16:10 +0100 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2022-08-25 12:16:10 +0100 |
commit | d619dd712f63aab1964f8fdde9ceea514a5e581d (patch) | |
tree | 31902c8248457622a7c21c3bbd31248316764397 /test/test_jsinterp.py | |
parent | 573b13410e5c2f939676116e2700ec8efd9cf97b (diff) |
[jsinterp] Fix bug in operator precedence
* from https://github.com/yt-dlp/yt-dlp/commit/164b03c4864b0d44cfee5e7702f7c2317164a6cf
* added tests
Diffstat (limited to 'test/test_jsinterp.py')
-rw-r--r-- | test/test_jsinterp.py | 25 |
1 files changed, 25 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 } |