Skip to content

Commit 4ab5650

Browse files
author
Paolo Tranquilli
committedJan 17, 2025
Python: add some more FP tests around match
1 parent 0d52541 commit 4ab5650

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| functions_test.py:18:1:18:11 | Function cr1 | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |
22
| functions_test.py:22:1:22:11 | Function cr2 | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |
33
| functions_test.py:336:1:336:16 | Function ok_match | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |
4+
| functions_test.py:344:1:344:17 | Function ok_match2 | Mixing implicit and explicit returns may indicate an error as implicit returns always return None. |

‎python/ql/test/query-tests/Functions/return_values/functions_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,11 @@ def ok_match(x): # FP
339339
return 0
340340
case _:
341341
raise ValueError(x)
342+
343+
344+
def ok_match2(x): # FP
345+
match x:
346+
case None:
347+
return 0
348+
case _:
349+
return 1

‎python/ql/test/query-tests/Statements/unreachable/UnreachableCode.expected

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
| test.py:21:5:21:38 | For | This statement is unreachable. |
55
| test.py:28:9:28:21 | ExprStmt | This statement is unreachable. |
66
| test.py:84:5:84:21 | ExceptStmt | This statement is unreachable. |
7+
| test.py:158:9:159:16 | Case | This statement is unreachable. |
8+
| test.py:162:13:162:16 | Pass | This statement is unreachable. |
9+
| test.py:167:13:167:16 | Pass | This statement is unreachable. |

‎python/ql/test/query-tests/Statements/unreachable/test.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,29 @@ def unreachable_catch_all_raise(x):
141141
def ok_match(x):
142142
match x:
143143
case False:
144-
pass # FP
144+
pass
145145
case True:
146146
pass
147+
case _:
148+
pass
149+
150+
match x:
151+
case "true":
152+
pass
153+
case _:
154+
pass
155+
match x:
156+
case 42:
157+
pass
147158
case _: # FP
148159
pass
160+
match x:
161+
case None:
162+
pass # FP
163+
case _:
164+
pass
165+
match x:
166+
case 0.0:
167+
pass # FP
168+
case _:
169+
pass

0 commit comments

Comments
 (0)