forked from nightroman/PowerShellTraps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.test.ps1
More file actions
27 lines (22 loc) · 722 Bytes
/
.test.ps1
File metadata and controls
27 lines (22 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
task test.1.1.try {
($r = .\test.1.1.try.ps1)
equals 'This is invoked.' $r
}
task test.1.2.try {
($r = .\test.1.2.try.ps1)
equals 'Caught PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand' $r
}
task test.2.1.trap {
($r = .\test.2.1.trap)
equals 'This is invoked.' $r
}
task test.2.2.trap {
($r = .\test.2.2.trap.ps1)
equals 'Caught PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand' $r[0]
equals 'This is invoked due to continue in trap.' $r[1]
}
task test.2.3.trap {
($r = try {.\test.2.3.trap.ps1} catch {$_})
equals 'Caught PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand' $r[0]
equals $r[1].FullyQualifiedErrorId 'PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand'
}