Improve whitespace for Parser tests (#9806)
This commit is contained in:
parent
b4e2423fab
commit
f5e3de036e
|
@ -1,11 +1,11 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)" -Tags "CI" {
|
||||
BeforeAll {
|
||||
$functionDefinitionFile = Join-Path -Path $TestDrive -ChildPath "functionDefinition.ps1"
|
||||
$functionDefinition = @'
|
||||
function testcmd-parserbvt
|
||||
{
|
||||
function testcmd-parserbvt {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Position = 0)]
|
||||
|
@ -29,8 +29,7 @@ Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)"
|
|||
$ReturnType = "default"
|
||||
}
|
||||
|
||||
switch ( $ReturnType )
|
||||
{
|
||||
switch ( $ReturnType ) {
|
||||
"default" {
|
||||
$result = "$Property1;$Property2;$Property3"
|
||||
break
|
||||
|
@ -90,12 +89,10 @@ Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)"
|
|||
$shellfile = Join-Path -Path $TestDrive -ChildPath "testfile.cmd"
|
||||
$testfolder1 = Join-Path -Path $TestDrive -ChildPath "dir1"
|
||||
$testfolder2 = Join-Path -Path $testfolder1 -ChildPath "dir2"
|
||||
if(-Not(Test-Path $testfolder1))
|
||||
{
|
||||
if (-Not(Test-Path $testfolder1)) {
|
||||
New-Item $testfolder1 -Type Directory
|
||||
}
|
||||
if(-Not(Test-Path $testfolder2))
|
||||
{
|
||||
if (-Not(Test-Path $testfolder2)) {
|
||||
New-Item $testfolder2 -Type Directory
|
||||
}
|
||||
$testdirfile1 = Join-Path -Path $testfolder2 -ChildPath "testdirfile1.txt"
|
||||
|
@ -104,35 +101,28 @@ Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)"
|
|||
"">$testdirfile2
|
||||
}
|
||||
AfterEach {
|
||||
if(Test-Path $testfile)
|
||||
{
|
||||
if (Test-Path $testfile) {
|
||||
Remove-Item $testfile
|
||||
}
|
||||
if(Test-Path $shellfile)
|
||||
{
|
||||
if (Test-Path $shellfile) {
|
||||
Remove-Item $shellfile
|
||||
}
|
||||
if(Test-Path $testdirfile1)
|
||||
{
|
||||
if (Test-Path $testdirfile1) {
|
||||
Remove-Item $testdirfile1
|
||||
}
|
||||
if(Test-Path $testdirfile2)
|
||||
{
|
||||
if (Test-Path $testdirfile2) {
|
||||
Remove-Item $testdirfile2
|
||||
}
|
||||
if(Test-Path $testfolder2)
|
||||
{
|
||||
if (Test-Path $testfolder2) {
|
||||
Remove-Item $testfolder2
|
||||
}
|
||||
if(Test-Path $testfolder1)
|
||||
{
|
||||
if (Test-Path $testfolder1) {
|
||||
Remove-Item $testfolder1
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
if(Test-Path $functionDefinitionFile)
|
||||
{
|
||||
if (Test-Path $functionDefinitionFile) {
|
||||
Remove-Item $functionDefinitionFile
|
||||
}
|
||||
}
|
||||
|
@ -364,8 +354,7 @@ foo``u{2195}abc
|
|||
" foreach(`$a in 1,2,3) { 1; foreach( `$b in 1,2,3 ) { 2; break; 3; }; 4; break; 5; } "
|
||||
$results = "1", "2", "4"
|
||||
$i = 0
|
||||
for(;$i -lt $commands.Count;$i++)
|
||||
{
|
||||
for (; $i -lt $commands.Count; $i++) {
|
||||
$result = ExecuteCommand $commands[$i]
|
||||
$result | Should -Be $results
|
||||
}
|
||||
|
@ -377,8 +366,7 @@ foo``u{2195}abc
|
|||
" :foo foreach(`$a in 1,2,3) { 1; :foo foreach( `$b in 1,2,3 ) { 2; break foo; 3; }; 4; break; 5; } "
|
||||
$results = "1", "2", "4"
|
||||
$i = 0
|
||||
for(;$i -lt $commands.Count;$i++)
|
||||
{
|
||||
for (; $i -lt $commands.Count; $i++) {
|
||||
$result = ExecuteCommand $commands[$i]
|
||||
$result | Should -Be $results
|
||||
}
|
||||
|
@ -1063,15 +1051,24 @@ foo``u{2195}abc
|
|||
|
||||
Context "Mathematical Operations Tests (starting at line 2975 to line 3036)" {
|
||||
$testData = @(
|
||||
@{ Script = '$a=6; $a -= 2;$a'; Expected = 4 }
|
||||
@{ Script = "20 %
|
||||
6"; Expected = "2" }
|
||||
@{ Script = "(20 %
|
||||
@{
|
||||
Script = '$a=6; $a -= 2;$a'
|
||||
Expected = 4
|
||||
}
|
||||
@{
|
||||
Script = "20 %
|
||||
6"
|
||||
Expected = "2"
|
||||
}
|
||||
@{
|
||||
Script = "(20 %
|
||||
6 *
|
||||
4 +
|
||||
2 ) /
|
||||
2 -
|
||||
3"; Expected = "2" }
|
||||
3"
|
||||
Expected = "2"
|
||||
}
|
||||
)
|
||||
It "<Script> should return <Expected>" -TestCases $testData {
|
||||
param ( $Script, $Expected )
|
||||
|
|
Loading…
Reference in a new issue