Skip to content

Commit 800f6dd

Browse files
committed
PS: Add a test demonstraing missing arguments for object creations.
1 parent 255aa39 commit 800f6dd

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
forEach
12
| graph/functions.ps1:29:5:32:5 | forach(... in ...) | graph/functions.ps1:29:14:29:20 | number | graph/functions.ps1:29:25:29:32 | numbers | graph/functions.ps1:29:35:32:5 | {...} |
23
| graph/loops.ps1:52:5:55:5 | forach(... in ...) | graph/loops.ps1:52:14:52:20 | letter | graph/loops.ps1:52:25:52:36 | letterArray | graph/loops.ps1:53:5:55:5 | {...} |
4+
objectCreation
5+
| graph/exprs.ps1:2:10:2:91 | Call to new-object | 0 | graph/exprs.ps1:2:21:2:71 | Microsoft.Data.SqlClient.SqlConnectionStringBuilder |

powershell/ql/test/library-tests/controlflow/elements.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ query predicate forEach(ForEachStmtCfgNode forEach, ExprCfgNode va, ExprCfgNode
66
va = forEach.getVarAccess() and
77
iterable = forEach.getIterableExpr() and
88
body = forEach.getBody()
9+
}
10+
11+
query predicate objectCreation(ObjectCreationCfgNode oc, int i, ExprCfgNode argument) {
12+
argument = oc.getArgument(i)
913
}

powershell/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,22 @@
218218
| conditionals.ps1:124:5:124:6 | a | conditionals.ps1:123:33:129:1 | exit {...} (normal) | |
219219
| conditionals.ps1:124:5:128:5 | ...=... | conditionals.ps1:124:5:124:6 | a | |
220220
| conditionals.ps1:124:5:128:5 | {...} | conditionals.ps1:124:5:128:5 | ...=... | |
221+
| exprs.ps1:1:1:3:1 | def of objectCreation | exprs.ps1:1:1:3:1 | exit {...} (normal) | |
222+
| exprs.ps1:1:1:3:1 | enter {...} | exprs.ps1:1:1:3:1 | {...} | |
223+
| exprs.ps1:1:1:3:1 | exit {...} (normal) | exprs.ps1:1:1:3:1 | exit {...} | |
224+
| exprs.ps1:1:1:3:1 | {...} | exprs.ps1:1:1:3:1 | def of objectCreation | |
225+
| exprs.ps1:1:1:3:1 | {...} | exprs.ps1:1:1:3:1 | {...} | |
226+
| exprs.ps1:1:25:3:1 | [synth] pipeline | exprs.ps1:2:5:2:91 | {...} | |
227+
| exprs.ps1:1:25:3:1 | enter {...} | exprs.ps1:1:25:3:1 | {...} | |
228+
| exprs.ps1:1:25:3:1 | exit {...} (normal) | exprs.ps1:1:25:3:1 | exit {...} | |
229+
| exprs.ps1:1:25:3:1 | {...} | exprs.ps1:1:25:3:1 | [synth] pipeline | |
230+
| exprs.ps1:2:5:2:6 | x | exprs.ps1:2:10:2:19 | New-Object | |
231+
| exprs.ps1:2:5:2:91 | ...=... | exprs.ps1:2:5:2:6 | x | |
232+
| exprs.ps1:2:5:2:91 | {...} | exprs.ps1:2:5:2:91 | ...=... | |
233+
| exprs.ps1:2:10:2:19 | New-Object | exprs.ps1:2:21:2:71 | Microsoft.Data.SqlClient.SqlConnectionStringBuilder | |
234+
| exprs.ps1:2:10:2:91 | Call to new-object | exprs.ps1:1:25:3:1 | exit {...} (normal) | |
235+
| exprs.ps1:2:21:2:71 | Microsoft.Data.SqlClient.SqlConnectionStringBuilder | exprs.ps1:2:87:2:91 | arg | |
236+
| exprs.ps1:2:87:2:91 | arg | exprs.ps1:2:10:2:91 | Call to new-object | |
221237
| functions.ps1:1:1:9:1 | def of Add-Numbers-Arguments | functions.ps1:11:1:11:28 | def of foo | |
222238
| functions.ps1:1:1:52:1 | {...} | functions.ps1:1:1:9:1 | def of Add-Numbers-Arguments | |
223239
| functions.ps1:1:1:54:0 | enter {...} | functions.ps1:1:1:54:0 | {...} | |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function objectCreation {
2+
$x = New-Object Microsoft.Data.SqlClient.SqlConnectionStringBuilder -ArgumentList "arg"
3+
}

0 commit comments

Comments
 (0)