-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy path.test.ps1
62 lines (55 loc) · 1.46 KB
/
.test.ps1
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$Version = $PSVersionTable.PSVersion.Major
task test.1.invocation {
($r = .\test.1.invocation.ps1)
equals $r.Count 2
if ($Version -ge 7) {
equals $r[0] 42
equals $r[1] 42
}
elseif ($Version -ge 5) {
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[0].CategoryInfo)
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[1].CategoryInfo)
}
else {
equals 42 $r[0]
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[1].CategoryInfo)
}
}
task test.2.dot-sourcing {
($r = try {.\test.2.dot-sourcing.ps1} catch {$_})
equals $r.Count 2
if ($Version -ge 7) {
equals $r[0] 42
equals $r[1] 42
}
elseif ($Version -ge 5) {
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[0].CategoryInfo)
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[1].CategoryInfo)
}
else {
equals 42 $r[0]
assert ('NotSpecified: (:) [], WildcardPatternException' -eq $r[1].CategoryInfo)
}
}
task test.3.escaped {
($r = .\test.3.escaped.ps1)
equals $r.Count 4
if ($Version -ge 7) {
equals $r[0].FullyQualifiedErrorId CommandNotFoundException
equals $r[1] 42
equals $r[2] 42
equals $r[3] 42
}
elseif ($Version -ge 5) {
equals $r[0] 42
equals $r[1] 42
equals $r[2] 42
equals $r[3] 42
}
else {
equals $r[0] 42
equals $r[1].FullyQualifiedErrorId CommandNotFoundException
equals $r[2].FullyQualifiedErrorId CommandNotFoundException
equals $r[3].FullyQualifiedErrorId CommandNotFoundException
}
}