summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-04-28 20:25:48 (GMT)
committerGitHub <noreply@github.com>2023-04-28 20:25:48 (GMT)
commit79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef (patch)
tree36f0645d165e50acfca05e3f17fb3d175e1c6334
parent689723a4abdc1e61a9f71db8ff40886ae1b1704d (diff)
downloadcpython-79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef.zip
cpython-79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef.tar.gz
cpython-79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef.tar.bz2
GH-103971: Forward-port test from GH-103980 (GH-103984)
-rw-r--r--Lib/test/test_patma.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py
index 0ed5407..3dbd19d 100644
--- a/Lib/test/test_patma.py
+++ b/Lib/test/test_patma.py
@@ -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.