-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
.test.ps1
63 lines (55 loc) · 1.13 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
63
$v2 = $PSVersionTable.PSVersion.Major -eq 2
$v610 = $PSVersionTable.PSVersion -gt ([version]'6.0.9999')
task test1.no.results {
($r = .\test1.no.results.ps1)
if ($v2) {
equals $null $r
}
else {
equals 0 $r
}
}
task test1.no.results.strict {
($r = try {.\test1.no.results.strict.ps1} catch {$_})
equals $r.FullyQualifiedErrorId 'PropertyNotFoundStrict'
}
task test2.one.object.Count {
($r = .\test2.one.object.Count.ps1)
if ($v2) {
equals $null $r
}
else {
equals 1 $r
}
}
task test2.one.object.Count.strict {
($r = try {.\test2.one.object.Count.strict.ps1} catch {$_})
equals $r.FullyQualifiedErrorId 'PropertyNotFoundStrict'
}
task test3.one.object.Length {
($r = .\test3.one.object.Length.ps1)
equals 6 $r
}
task test4.one.object.Count {
($r = .\test4.one.object.Count.ps1)
equals 3 $r
}
task test5.PSCustomObject {
($r = ./test5.PSCustomObject.ps1)
equals $r.Count 3
if ($v610) {
equals $r[0] 1
equals $r[1] $false
equals $r[2] PSCustomObject
}
elseif ($v2) {
equals $r[0] 2
equals $r[1] $false
equals $r[2] Hashtable
}
else {
equals $r[0] $null
equals $r[1] $true
equals $r[2] PSCustomObject
}
}