-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy path.test.ps1
32 lines (29 loc) · 897 Bytes
/
.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
$Version = $PSVersionTable.PSVersion
${5.0} = [version]'5.0.0'
${5.1} = [version]'5.1.0'
${6.1} = [version]'6.0.9999' # 6.1-preview.2
if ($Version -lt ${5.0}) {return task test5}
task Test-1.fails {
($r = try {.\Test-1.fails.ps1} catch {$_})
if ($Version -ge ${6.1}) {
equals $r.FullyQualifiedErrorId 'System.NullReferenceException,Test-1.fails.ps1'
}
elseif ($Version -ge ${5.1}) {
# weird error "Parameter name: type" with no source
equals $r.FullyQualifiedErrorId 'System.ArgumentNullException,Test-1.fails.ps1'
}
else {
equals $r.Count 2
assert ($r[0].GetType().FullName -cmatch '^<\w{8}>\.A$')
equals $r[1].FullyQualifiedErrorId TypeNotFound
}
}
task Test-2.works {
($r = .\Test-2.works.ps1)
equals $r.Count 2
$r0 = $r[0].GetType().FullName
$r1 = $r[1].GetType().FullName
assert ($r0 -cmatch '^<\w+>\.A$')
assert ($r1 -cmatch '^<\w+>\.A$')
assert ($r0 -ne $r1)
}