Skip to content

Commit 93aaa59

Browse files
committed
Add test changes
1 parent 71efc2b commit 93aaa59

File tree

1 file changed

+41
-30
lines changed

1 file changed

+41
-30
lines changed

Tests/Rules/AvoidGlobalOrUnitializedVarsNoViolations.ps1

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
function Test {
2-
$initialized = "Initialized"
3-
$noglobal = "local"
4-
$env:ShouldNotRaiseError
5-
}
6-
7-
$a = 3;
8-
9-
if ($true) {
10-
$a = 4;
11-
$c = 3;
12-
} else {
13-
$b = 5;
14-
$c = 4;
15-
}
16-
17-
$b = 6;
18-
$a;
19-
$b;
20-
21-
stop-process 12,23 -ErrorVariable ev -ErrorAction SilentlyContinue
22-
if($null -ne $ev)
23-
{
24-
Write-host $ev[0]
25-
# no error should be raised here
26-
Invoke-Command {$b}
27-
}
28-
29-
get-process notepad | tee-object -variable proc
30-
$proc[0]
1+
function Test {
2+
$initialized = "Initialized"
3+
$noglobal = "local"
4+
$env:ShouldNotRaiseError
5+
}
6+
7+
$a = 3;
8+
9+
if ($true) {
10+
$a = 4;
11+
$c = 3;
12+
} else {
13+
$b = 5;
14+
$c = 4;
15+
}
16+
17+
$b = 6;
18+
$a;
19+
$b;
20+
21+
stop-process 12,23 -ErrorVariable ev -ErrorAction SilentlyContinue
22+
if($null -ne $ev)
23+
{
24+
Write-host $ev[0]
25+
# no error should be raised here
26+
Invoke-Command {$b}
27+
}
28+
29+
get-process notepad | tee-object -variable proc
30+
$proc[0]
31+
32+
function Test-PreferenceVariable
33+
{
34+
35+
if (-not $PSBoundParameters.ContainsKey('Verbose')) {
36+
$VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference') -as
37+
[System.Management.Automation.ActionPreference]
38+
}
39+
40+
$VerbosePreference
41+
}

0 commit comments

Comments
 (0)