about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authordf <fieldhouse@gmx.net>2021-11-04 12:48:06 +0000
committerdirkf <fieldhouse@gmx.net>2022-01-30 00:05:54 +0000
commite1eae16b56b5c57e341b000167c0a92e67095e6e (patch)
tree2b1185598a5294cf195267439e5e562867325b30 /test
parent96f87aaa3b34d80bc72097a7475d8093849091fc (diff)
downloadyoutube-dl-e1eae16b56b5c57e341b000167c0a92e67095e6e.tar.gz
youtube-dl-e1eae16b56b5c57e341b000167c0a92e67095e6e.tar.xz
youtube-dl-e1eae16b56b5c57e341b000167c0a92e67095e6e.zip
Handle default in switch better
Add https://github.com/yt-dlp/yt-dlp/commit/a1fc7ca0743c8df06416e68ee74b64e07dfe7135
Thanks coletdjnz
Diffstat (limited to 'test')
-rw-r--r--test/test_jsinterp.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py
index 4d05ea610..acdabffb1 100644
--- a/test/test_jsinterp.py
+++ b/test/test_jsinterp.py
@@ -133,6 +133,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} }