Skip to content

Commit 920b671

Browse files
xtqqczzedaxian-dbw
authored andcommitted
Unify pester test syntax for the arguments of -BeOfType (#11558)
1 parent a7a2b12 commit 920b671

68 files changed

Lines changed: 216 additions & 216 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/powershell/Host/ConsoleHost.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ Describe 'minishell for native executables' -Tag 'CI' {
1919
It 'gets a hashtable object from minishell' {
2020
$output = & $powershell -noprofile { @{'a' = 'b'} }
2121
($output | Measure-Object).Count | Should -Be 1
22-
$output | Should -BeOfType 'Hashtable'
22+
$output | Should -BeOfType Hashtable
2323
$output['a'] | Should -Be 'b'
2424
}
2525

2626
It 'gets the error stream from minishell' {
2727
$output = & $powershell -noprofile { Write-Error 'foo' } 2>&1
2828
($output | Measure-Object).Count | Should -Be 1
29-
$output | Should -BeOfType 'System.Management.Automation.ErrorRecord'
29+
$output | Should -BeOfType System.Management.Automation.ErrorRecord
3030
$output.FullyQualifiedErrorId | Should -Be 'Microsoft.PowerShell.Commands.WriteErrorException'
3131
}
3232

3333
It 'gets the information stream from minishell' {
3434
$output = & $powershell -noprofile { Write-Information 'foo' } 6>&1
3535
($output | Measure-Object).Count | Should -Be 1
36-
$output | Should -BeOfType 'System.Management.Automation.InformationRecord'
36+
$output | Should -BeOfType System.Management.Automation.InformationRecord
3737
$output | Should -Be 'foo'
3838
}
3939
}

test/powershell/Host/PSVersionTable.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ Describe "PSVersionTable" -Tags "CI" {
4646
}
4747

4848
It "PSVersion property" {
49-
$PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion"
49+
$PSVersionTable.PSVersion | Should -BeOfType System.Management.Automation.SemanticVersion
5050
$PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion
5151
$PSVersionTable.PSVersion | Should -Match $expectedVersionPattern
5252
$PSVersionTable.PSVersion.Major | Should -Be 7
5353
}
5454

5555
It "GitCommitId property" {
56-
$PSVersionTable.GitCommitId | Should -BeOfType "System.String"
56+
$PSVersionTable.GitCommitId | Should -BeOfType System.String
5757
$PSVersionTable.GitCommitId | Should -Match $expectedGitCommitIdPattern
5858
$PSVersionTable.GitCommitId | Should -Not -Match $unexpectectGitCommitIdPattern
5959
$PSVersionTable.GitCommitId | Should -BeExactly $rawGitCommitId

test/powershell/Language/Classes/Scripting.Classes.Exceptions.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Describe "Exception from initializer" -Tags "CI" {
290290

291291
It "static member w/ ctor" {
292292
$e = { $null = [MSFT_6397334c]::a } | Should -Throw -PassThru
293-
$e.Exception | Should -BeOfType 'System.TypeInitializationException'
293+
$e.Exception | Should -BeOfType System.TypeInitializationException
294294
$e.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -BeExactly 'InvalidCastFromStringToInteger'
295295
$e.Exception.InnerException.InnerException.ErrorRecord.InvocationInfo.Line | Should -Match 'a = "zz"'
296296
}

test/powershell/Language/Operators/RangeOperator.Tests.ps1

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Describe "Range Operator" -Tags CI {
55
It "Range operator generates arrays of integers" {
66
$Range = 5..8
77
$Range.count | Should -Be 4
8-
$Range[0] | Should -BeOfType [int]
9-
$Range[1] | Should -BeOfType [int]
10-
$Range[2] | Should -BeOfType [int]
11-
$Range[3] | Should -BeOfType [int]
8+
$Range[0] | Should -BeOfType int
9+
$Range[1] | Should -BeOfType int
10+
$Range[2] | Should -BeOfType int
11+
$Range[3] | Should -BeOfType int
1212

1313
$Range[0] | Should -Be 5
1414
$Range[1] | Should -Be 6
@@ -28,7 +28,7 @@ Describe "Range Operator" -Tags CI {
2828
It "Range operator support single-item sequences" {
2929
$Range = 0..0
3030
$Range.count | Should -Be 1
31-
$Range[0] | Should -BeOfType [int]
31+
$Range[0] | Should -BeOfType int
3232
$Range[0] | Should -Be 0
3333
}
3434

@@ -92,21 +92,21 @@ Describe "Range Operator" -Tags CI {
9292
It "Range operator generates an array of [char] from single-character operands" {
9393
$CharRange = 'A'..'E'
9494
$CharRange.count | Should -Be 5
95-
$CharRange[0] | Should -BeOfType [char]
96-
$CharRange[1] | Should -BeOfType [char]
97-
$CharRange[2] | Should -BeOfType [char]
98-
$CharRange[3] | Should -BeOfType [char]
99-
$CharRange[4] | Should -BeOfType [char]
95+
$CharRange[0] | Should -BeOfType char
96+
$CharRange[1] | Should -BeOfType char
97+
$CharRange[2] | Should -BeOfType char
98+
$CharRange[3] | Should -BeOfType char
99+
$CharRange[4] | Should -BeOfType char
100100
}
101101

102102
It "Range operator enumerator generates an array of [string] from single-character operands" {
103103
$CharRange = 'A'..'E' | ForEach-Object { $_ }
104104
$CharRange.count | Should -Be 5
105-
$CharRange[0] | Should -BeOfType [char]
106-
$CharRange[1] | Should -BeOfType [char]
107-
$CharRange[2] | Should -BeOfType [char]
108-
$CharRange[3] | Should -BeOfType [char]
109-
$CharRange[4] | Should -BeOfType [char]
105+
$CharRange[0] | Should -BeOfType char
106+
$CharRange[1] | Should -BeOfType char
107+
$CharRange[2] | Should -BeOfType char
108+
$CharRange[3] | Should -BeOfType char
109+
$CharRange[4] | Should -BeOfType char
110110
}
111111

112112
It "Range operator works in ascending and descending order" {

test/powershell/Language/Operators/TernaryOperator.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Describe "Using of ternary operator" -Tags CI {
7171
It "Use ternary operator with assignments" {
7272
$IsCoreCLR ? ([string]$var = 'string') : 'blah' > $null
7373
$var = [System.IO.FileInfo]::new('abc')
74-
$var | Should -BeOfType [string]
74+
$var | Should -BeOfType string
7575
$var | Should -BeExactly 'abc'
7676
}
7777

@@ -82,7 +82,7 @@ Describe "Using of ternary operator" -Tags CI {
8282

8383
It "Return script block from ternary expression" {
8484
$result = ${IsCoreCLR}?{'Core'}:{'Desktop'}
85-
$result | Should -BeOfType [scriptblock]
85+
$result | Should -BeOfType scriptblock
8686
& $result | Should -BeExactly 'Core'
8787
}
8888

test/powershell/Language/Parser/Ast.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Describe "The SafeGetValue method on AST returns safe values" -Tags "CI" {
88
@{ one = 1 }
99
}.ast.Find({$args[0] -is $HashtableAstType}, $true)
1010
$HtAst | Should -Not -BeNullOrEmpty
11-
$HtAst.SafeGetValue() | Should -BeOfType "Hashtable"
11+
$HtAst.SafeGetValue() | Should -BeOfType Hashtable
1212
}
1313
It "An Array is returned from a LiteralArrayAst" {
1414
$ArrayAstType = [ArrayLiteralAst]
1515
$ArrayAst = {
1616
@( 1,2,3,4)
1717
}.ast.Find({$args[0] -is $ArrayAstType}, $true)
1818
$ArrayAst | Should -Not -BeNullOrEmpty
19-
,$ArrayAst.SafeGetValue() | Should -BeOfType "Object[]"
19+
,$ArrayAst.SafeGetValue() | Should -BeOfType Object[]
2020
}
2121
It "The proper error is returned when a variable is referenced" {
2222
$ast = { $a }.Ast.Find({$args[0] -is "VariableExpressionAst"},$true)

test/powershell/Language/Parser/Parser.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ foo``u{2195}abc
677677
It "Test that typing a number at the command line will return that number. (line 1630)" {
678678
$result = ExecuteCommand '3'
679679
$result | Should -Be "3"
680-
$result | Should -BeOfType [int]
680+
$result | Should -BeOfType int
681681
}
682682

683683
It "This test will check that an msh script can be run without invoking. (line 1641)" {

test/powershell/Language/Parser/Parsing.Tests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,10 @@ Describe "Ternary Operator parsing" -Tags CI {
401401
$tks[0].Text | Should -BeExactly $Script
402402

403403
if ($TokenKind -eq "Variable") {
404-
$result.EndBlock.Statements[0].PipelineElements[0].Expression | Should -BeOfType 'System.Management.Automation.Language.VariableExpressionAst'
404+
$result.EndBlock.Statements[0].PipelineElements[0].Expression | Should -BeOfType System.Management.Automation.Language.VariableExpressionAst
405405
$result.EndBlock.Statements[0].PipelineElements[0].Expression.Extent.Text | Should -BeExactly $Script
406406
} else {
407-
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0] | Should -BeOfType 'System.Management.Automation.Language.StringConstantExpressionAst'
407+
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0] | Should -BeOfType System.Management.Automation.Language.StringConstantExpressionAst
408408
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0].Extent.Text | Should -BeExactly $Script
409409
}
410410
}
@@ -441,9 +441,9 @@ Describe "Ternary Operator parsing" -Tags CI {
441441
$ers[1].ErrorId | Should -BeExactly 'ExpectedValueExpression'
442442

443443
$expr = $result.EndBlock.Statements[0].PipelineElements[0].Expression
444-
$expr | Should -BeOfType 'System.Management.Automation.Language.TernaryExpressionAst'
445-
$expr.IfTrue | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
446-
$expr.IfFalse | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
444+
$expr | Should -BeOfType System.Management.Automation.Language.TernaryExpressionAst
445+
$expr.IfTrue | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
446+
$expr.IfFalse | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
447447
}
448448

449449
It "Generate ternary AST when operands are missing - '`$true ? : 3'" {
@@ -454,8 +454,8 @@ Describe "Ternary Operator parsing" -Tags CI {
454454
$ers.IncompleteInput | Should -BeFalse
455455
$ers.ErrorId | Should -BeExactly "ExpectedValueExpression"
456456
$expr = $result.EndBlock.Statements[0].PipelineElements[0].Expression
457-
$expr | Should -BeOfType 'System.Management.Automation.Language.TernaryExpressionAst'
458-
$expr.IfTrue | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
459-
$expr.IfFalse | Should -BeOfType 'System.Management.Automation.Language.ConstantExpressionAst'
457+
$expr | Should -BeOfType System.Management.Automation.Language.TernaryExpressionAst
458+
$expr.IfTrue | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
459+
$expr.IfFalse | Should -BeOfType System.Management.Automation.Language.ConstantExpressionAst
460460
}
461461
}

test/powershell/Language/Scripting/ActionPreference.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ Describe "Tests for (error, warning, etc) action preference" -Tags "CI" {
7878

7979
It '$err.Count' { $err.Count | Should -Be 1 }
8080
It '$err[0] should not be $null' { $err[0] | Should -Not -BeNullOrEmpty }
81-
It '$err[0].GetType().Name' { $err[0] | Should -BeOfType "System.Management.Automation.ActionPreferenceStopException" }
81+
It '$err[0].GetType().Name' { $err[0] | Should -BeOfType System.Management.Automation.ActionPreferenceStopException }
8282
It '$err[0].ErrorRecord' { $err[0].ErrorRecord | Should -Not -BeNullOrEmpty }
83-
It '$err[0].ErrorRecord.Exception.GetType().Name' { $err[0].ErrorRecord.Exception | Should -BeOfType "System.Management.Automation.ItemNotFoundException" }
83+
It '$err[0].ErrorRecord.Exception.GetType().Name' { $err[0].ErrorRecord.Exception | Should -BeOfType System.Management.Automation.ItemNotFoundException }
8484
}
8585

8686
It 'Action preference of Ignore can be set as a preference variable using a string value' {

test/powershell/Language/Scripting/HashtableToPSCustomObjectConversion.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
4343
It 'Hashtable conversion to PSCustomObject retains insertion order of hashtable keys when passed a hashliteral' {
4444

4545
$x = [pscustomobject]@{one=1;two=2}
46-
$x | Should -BeOfType "System.Management.automation.psobject"
46+
$x | Should -BeOfType System.Management.automation.psobject
4747

4848
$p = 0
4949
# Checks if the first property is One
@@ -60,7 +60,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
6060
It 'Conversion of Ordered hashtable to PSCustomObject should succeed' {
6161

6262
$x = [pscustomobject][ordered]@{one=1;two=2}
63-
$x | Should -BeOfType "System.Management.automation.psobject"
63+
$x | Should -BeOfType System.Management.automation.psobject
6464

6565
$p = 0
6666
# Checks if the first property is One

0 commit comments

Comments
 (0)