Skip to content

Commit 8614563

Browse files
committed
Python: More tests of syntactic constructs
1 parent 5bff518 commit 8614563

File tree

2 files changed

+95
-37
lines changed

2 files changed

+95
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,55 @@
11
edges
2-
| test.py:2:12:2:12 | ControlFlowNode for l | test.py:3:5:3:5 | ControlFlowNode for l |
3-
| test.py:13:13:13:13 | ControlFlowNode for l | test.py:14:5:14:5 | ControlFlowNode for l |
4-
| test.py:18:14:18:14 | ControlFlowNode for l | test.py:19:13:19:13 | ControlFlowNode for l |
5-
| test.py:19:13:19:13 | ControlFlowNode for l | test.py:13:13:13:13 | ControlFlowNode for l |
6-
| test.py:23:14:23:14 | ControlFlowNode for l | test.py:24:5:24:5 | ControlFlowNode for l |
7-
| test.py:52:17:52:17 | ControlFlowNode for d | test.py:53:5:53:5 | ControlFlowNode for d |
8-
| test.py:57:26:57:26 | ControlFlowNode for d | test.py:58:5:58:5 | ControlFlowNode for d |
9-
| test.py:62:35:62:35 | ControlFlowNode for d | test.py:63:5:63:5 | ControlFlowNode for d |
10-
| test.py:66:21:66:21 | ControlFlowNode for d | test.py:67:5:67:5 | ControlFlowNode for d |
11-
| test.py:71:26:71:26 | ControlFlowNode for d | test.py:72:21:72:21 | ControlFlowNode for d |
12-
| test.py:72:21:72:21 | ControlFlowNode for d | test.py:66:21:66:21 | ControlFlowNode for d |
2+
| test.py:17:15:17:15 | ControlFlowNode for l | test.py:18:5:18:5 | ControlFlowNode for l |
3+
| test.py:22:15:22:15 | ControlFlowNode for l | test.py:23:5:23:5 | ControlFlowNode for l |
4+
| test.py:27:12:27:12 | ControlFlowNode for l | test.py:28:5:28:5 | ControlFlowNode for l |
5+
| test.py:38:13:38:13 | ControlFlowNode for l | test.py:39:5:39:5 | ControlFlowNode for l |
6+
| test.py:43:14:43:14 | ControlFlowNode for l | test.py:44:13:44:13 | ControlFlowNode for l |
7+
| test.py:44:13:44:13 | ControlFlowNode for l | test.py:38:13:38:13 | ControlFlowNode for l |
8+
| test.py:48:14:48:14 | ControlFlowNode for l | test.py:49:5:49:5 | ControlFlowNode for l |
9+
| test.py:77:17:77:17 | ControlFlowNode for d | test.py:78:5:78:5 | ControlFlowNode for d |
10+
| test.py:82:26:82:26 | ControlFlowNode for d | test.py:83:5:83:5 | ControlFlowNode for d |
11+
| test.py:87:35:87:35 | ControlFlowNode for d | test.py:88:5:88:5 | ControlFlowNode for d |
12+
| test.py:91:21:91:21 | ControlFlowNode for d | test.py:92:5:92:5 | ControlFlowNode for d |
13+
| test.py:96:26:96:26 | ControlFlowNode for d | test.py:97:21:97:21 | ControlFlowNode for d |
14+
| test.py:97:21:97:21 | ControlFlowNode for d | test.py:91:21:91:21 | ControlFlowNode for d |
15+
| test.py:113:20:113:20 | ControlFlowNode for d | test.py:115:5:115:5 | ControlFlowNode for d |
16+
| test.py:119:29:119:29 | ControlFlowNode for d | test.py:121:5:121:5 | ControlFlowNode for d |
1317
nodes
14-
| test.py:2:12:2:12 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
15-
| test.py:3:5:3:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
16-
| test.py:13:13:13:13 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
17-
| test.py:14:5:14:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
18-
| test.py:18:14:18:14 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
19-
| test.py:19:13:19:13 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
20-
| test.py:23:14:23:14 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
21-
| test.py:24:5:24:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
22-
| test.py:52:17:52:17 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
23-
| test.py:53:5:53:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
24-
| test.py:57:26:57:26 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
25-
| test.py:58:5:58:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
26-
| test.py:62:35:62:35 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
27-
| test.py:63:5:63:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
28-
| test.py:66:21:66:21 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
29-
| test.py:67:5:67:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
30-
| test.py:71:26:71:26 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
31-
| test.py:72:21:72:21 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
18+
| test.py:17:15:17:15 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
19+
| test.py:18:5:18:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
20+
| test.py:22:15:22:15 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
21+
| test.py:23:5:23:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
22+
| test.py:27:12:27:12 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
23+
| test.py:28:5:28:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
24+
| test.py:38:13:38:13 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
25+
| test.py:39:5:39:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
26+
| test.py:43:14:43:14 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
27+
| test.py:44:13:44:13 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
28+
| test.py:48:14:48:14 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
29+
| test.py:49:5:49:5 | ControlFlowNode for l | semmle.label | ControlFlowNode for l |
30+
| test.py:77:17:77:17 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
31+
| test.py:78:5:78:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
32+
| test.py:82:26:82:26 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
33+
| test.py:83:5:83:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
34+
| test.py:87:35:87:35 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
35+
| test.py:88:5:88:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
36+
| test.py:91:21:91:21 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
37+
| test.py:92:5:92:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
38+
| test.py:96:26:96:26 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
39+
| test.py:97:21:97:21 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
40+
| test.py:113:20:113:20 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
41+
| test.py:115:5:115:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
42+
| test.py:119:29:119:29 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
43+
| test.py:121:5:121:5 | ControlFlowNode for d | semmle.label | ControlFlowNode for d |
3244
#select
33-
| test.py:3:5:3:5 | ControlFlowNode for l | test.py:2:12:2:12 | ControlFlowNode for l | test.py:3:5:3:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:2:12:2:12 | ControlFlowNode for l | Default value |
34-
| test.py:14:5:14:5 | ControlFlowNode for l | test.py:18:14:18:14 | ControlFlowNode for l | test.py:14:5:14:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:18:14:18:14 | ControlFlowNode for l | Default value |
35-
| test.py:24:5:24:5 | ControlFlowNode for l | test.py:23:14:23:14 | ControlFlowNode for l | test.py:24:5:24:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:23:14:23:14 | ControlFlowNode for l | Default value |
36-
| test.py:53:5:53:5 | ControlFlowNode for d | test.py:52:17:52:17 | ControlFlowNode for d | test.py:53:5:53:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:52:17:52:17 | ControlFlowNode for d | Default value |
37-
| test.py:58:5:58:5 | ControlFlowNode for d | test.py:57:26:57:26 | ControlFlowNode for d | test.py:58:5:58:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:57:26:57:26 | ControlFlowNode for d | Default value |
38-
| test.py:63:5:63:5 | ControlFlowNode for d | test.py:62:35:62:35 | ControlFlowNode for d | test.py:63:5:63:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:62:35:62:35 | ControlFlowNode for d | Default value |
39-
| test.py:67:5:67:5 | ControlFlowNode for d | test.py:71:26:71:26 | ControlFlowNode for d | test.py:67:5:67:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:71:26:71:26 | ControlFlowNode for d | Default value |
45+
| test.py:18:5:18:5 | ControlFlowNode for l | test.py:17:15:17:15 | ControlFlowNode for l | test.py:18:5:18:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:17:15:17:15 | ControlFlowNode for l | Default value |
46+
| test.py:23:5:23:5 | ControlFlowNode for l | test.py:22:15:22:15 | ControlFlowNode for l | test.py:23:5:23:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:22:15:22:15 | ControlFlowNode for l | Default value |
47+
| test.py:28:5:28:5 | ControlFlowNode for l | test.py:27:12:27:12 | ControlFlowNode for l | test.py:28:5:28:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:27:12:27:12 | ControlFlowNode for l | Default value |
48+
| test.py:39:5:39:5 | ControlFlowNode for l | test.py:43:14:43:14 | ControlFlowNode for l | test.py:39:5:39:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:43:14:43:14 | ControlFlowNode for l | Default value |
49+
| test.py:49:5:49:5 | ControlFlowNode for l | test.py:48:14:48:14 | ControlFlowNode for l | test.py:49:5:49:5 | ControlFlowNode for l | $@ flows to here and is mutated. | test.py:48:14:48:14 | ControlFlowNode for l | Default value |
50+
| test.py:78:5:78:5 | ControlFlowNode for d | test.py:77:17:77:17 | ControlFlowNode for d | test.py:78:5:78:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:77:17:77:17 | ControlFlowNode for d | Default value |
51+
| test.py:83:5:83:5 | ControlFlowNode for d | test.py:82:26:82:26 | ControlFlowNode for d | test.py:83:5:83:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:82:26:82:26 | ControlFlowNode for d | Default value |
52+
| test.py:88:5:88:5 | ControlFlowNode for d | test.py:87:35:87:35 | ControlFlowNode for d | test.py:88:5:88:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:87:35:87:35 | ControlFlowNode for d | Default value |
53+
| test.py:92:5:92:5 | ControlFlowNode for d | test.py:96:26:96:26 | ControlFlowNode for d | test.py:92:5:92:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:96:26:96:26 | ControlFlowNode for d | Default value |
54+
| test.py:115:5:115:5 | ControlFlowNode for d | test.py:113:20:113:20 | ControlFlowNode for d | test.py:115:5:115:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:113:20:113:20 | ControlFlowNode for d | Default value |
55+
| test.py:121:5:121:5 | ControlFlowNode for d | test.py:119:29:119:29 | ControlFlowNode for d | test.py:121:5:121:5 | ControlFlowNode for d | $@ flows to here and is mutated. | test.py:119:29:119:29 | ControlFlowNode for d | Default value |

python/ql/test/query-tests/Functions/ModificationOfParameterWithDefault/test.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Not OK
2-
def simple(l = []):
2+
def simple(l = [0]):
3+
l[0] = 1 # FN
4+
return l
5+
6+
# Not OK
7+
def slice(l = [0]):
8+
l[0:1] = 1 # FN
9+
return l
10+
11+
# Not OK
12+
def list_del(l = [0]):
13+
del l[0] # FN
14+
return l
15+
16+
# Not OK
17+
def append_op(l = []):
18+
l += 1
19+
return l
20+
21+
# Not OK
22+
def repeat_op(l = [0]):
23+
l *= 3
24+
return l
25+
26+
# Not OK
27+
def append(l = []):
328
l.append(1)
429
return l
530

@@ -78,3 +103,20 @@ def dict_includes(d = {}):
78103
x.update(d)
79104
x.update({'a': 1})
80105
return x
106+
107+
# Not OK
108+
def dict_del(d = {'a': 1}):
109+
del d['a'] # FN
110+
return d
111+
112+
# Not OK
113+
def dict_update_op(d = {}):
114+
x = {'a': 1}
115+
d |= x
116+
return d
117+
118+
# OK
119+
def dict_update_op_nochange(d = {}):
120+
x = {}
121+
d |= x # FP
122+
return d

0 commit comments

Comments
 (0)