]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-103971: Forward-port test from GH-103980 (GH-103984)
authorTian Gao <gaogaotiantian@hotmail.com>
Fri, 28 Apr 2023 20:25:48 +0000 (13:25 -0700)
committerGitHub <noreply@github.com>
Fri, 28 Apr 2023 20:25:48 +0000 (20:25 +0000)
Lib/test/test_patma.py

index 0ed54079c99b302525dcdab986895d4973118795..3dbd19dfffd31861ac20a3b5e0dcd7d5b974b179 100644 (file)
@@ -3165,6 +3165,19 @@ class TestTracing(unittest.TestCase):
         self.assertListEqual(self._trace(f, "go x"), [1, 2, 3])
         self.assertListEqual(self._trace(f, "spam"), [1, 2, 3])
 
+    def test_unreachable_code(self):
+        def f(command):               # 0
+            match command:            # 1
+                case 1:               # 2
+                    if False:         # 3
+                        return 1      # 4
+                case _:               # 5
+                    if False:         # 6
+                        return 0      # 7
+
+        self.assertListEqual(self._trace(f, 1), [1, 2, 3])
+        self.assertListEqual(self._trace(f, 0), [1, 2, 5, 6])
+
     def test_parser_deeply_nested_patterns(self):
         # Deeply nested patterns can cause exponential backtracking when parsing.
         # See gh-93671 for more information.