Skip to content

Commit dbfd070

Browse files
committed
PS: Add some tests for string literals.
1 parent a7c0305 commit dbfd070

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$x = "abc"
2+
Foo
3+
$y = 'def'
4+
$z = @"ghi
5+
"@
6+
$t = @'j"k"l
7+
'@
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
stringLiteral
2+
| String.ps1:1:6:1:10 | abc |
3+
| String.ps1:2:1:2:3 | Foo |
4+
| String.ps1:3:6:3:10 | def |
5+
| String.ps1:4:6:4:10 | |
6+
| String.ps1:6:10:8:0 | '@\nkl |
7+
stringConstantExpression
8+
| String.ps1:1:6:1:10 | abc |
9+
| String.ps1:2:1:2:3 | Foo |
10+
| String.ps1:3:6:3:10 | def |
11+
| String.ps1:4:6:4:10 | |
12+
| String.ps1:6:10:8:0 | '@\nkl |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import powershell
2+
3+
query predicate stringLiteral(StringLiteral sl) { any() }
4+
5+
query predicate stringConstantExpression(StringConstExpr sce) { any() }

powershell/ql/test/library-tests/ast/parent.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,25 @@
429429
| Statements/UseProcessBlockForPipelineCommand.ps1:6:9:6:13 | int | Statements/UseProcessBlockForPipelineCommand.ps1:5:9:7:15 | number |
430430
| Statements/UseProcessBlockForPipelineCommand.ps1:10:5:10:11 | Number | Statements/UseProcessBlockForPipelineCommand.ps1:10:5:10:11 | [Stmt] Number |
431431
| Statements/UseProcessBlockForPipelineCommand.ps1:10:5:10:11 | [Stmt] Number | Statements/UseProcessBlockForPipelineCommand.ps1:4:5:10:11 | {...} |
432+
| Strings/String.ps1:1:1:1:2 | x | Strings/String.ps1:1:1:1:10 | ...=... |
433+
| Strings/String.ps1:1:1:1:2 | x | Strings/String.ps1:1:1:8:0 | {...} |
434+
| Strings/String.ps1:1:1:1:10 | ...=... | Strings/String.ps1:1:1:8:0 | {...} |
435+
| Strings/String.ps1:1:1:8:0 | {...} | Strings/String.ps1:1:1:8:0 | toplevel function for String.ps1 |
436+
| Strings/String.ps1:1:1:8:0 | {...} | Strings/String.ps1:1:1:8:0 | {...} |
437+
| Strings/String.ps1:1:6:1:10 | abc | Strings/String.ps1:1:1:1:10 | ...=... |
438+
| Strings/String.ps1:2:1:2:3 | Call to foo | Strings/String.ps1:2:1:2:3 | [Stmt] Call to foo |
439+
| Strings/String.ps1:2:1:2:3 | Foo | Strings/String.ps1:2:1:2:3 | Call to foo |
440+
| Strings/String.ps1:2:1:2:3 | [Stmt] Call to foo | Strings/String.ps1:1:1:8:0 | {...} |
441+
| Strings/String.ps1:3:1:3:2 | y | Strings/String.ps1:1:1:8:0 | {...} |
442+
| Strings/String.ps1:3:1:3:2 | y | Strings/String.ps1:3:1:3:10 | ...=... |
443+
| Strings/String.ps1:3:1:3:10 | ...=... | Strings/String.ps1:1:1:8:0 | {...} |
444+
| Strings/String.ps1:3:6:3:10 | def | Strings/String.ps1:3:1:3:10 | ...=... |
445+
| Strings/String.ps1:4:1:4:2 | z | Strings/String.ps1:1:1:8:0 | {...} |
446+
| Strings/String.ps1:4:1:4:2 | z | Strings/String.ps1:4:1:4:10 | ...=... |
447+
| Strings/String.ps1:4:1:4:10 | ...=... | Strings/String.ps1:1:1:8:0 | {...} |
448+
| Strings/String.ps1:4:6:4:10 | | Strings/String.ps1:4:1:4:10 | ...=... |
449+
| Strings/String.ps1:5:1:6:9 | $t = @'j\n@ | Strings/String.ps1:5:1:6:9 | [Stmt] $t = @'j\n@ |
450+
| Strings/String.ps1:5:1:6:9 | [Stmt] $t = @'j\n@ | Strings/String.ps1:1:1:8:0 | {...} |
451+
| Strings/String.ps1:6:10:8:0 | '@\nkl | Strings/String.ps1:6:10:8:0 | Call to kl\r\n'@\r\n |
452+
| Strings/String.ps1:6:10:8:0 | Call to kl\r\n'@\r\n | Strings/String.ps1:6:10:8:0 | [Stmt] Call to kl\r\n'@\r\n |
453+
| Strings/String.ps1:6:10:8:0 | [Stmt] Call to kl\r\n'@\r\n | Strings/String.ps1:1:1:8:0 | {...} |

0 commit comments

Comments
 (0)