From 102082d9ed737d31ba31bbbcd2ae3d44e0ee70ea Mon Sep 17 00:00:00 2001 From: rzuckerm Date: Mon, 15 May 2023 09:50:39 -0500 Subject: [PATCH] Add Powershell Tests (#3093) --- .../{Fizz-Buzz.ps1 => FizzBuzz.ps1} | 4 ++-- .../{Hello-World.ps1 => HelloWorld.ps1} | 0 archive/p/powershell/README.md | 14 +++---------- .../{Reverse-String.ps1 => ReverseString.ps1} | 20 +++++++++---------- archive/p/powershell/testinfo.yml | 8 ++++++++ 5 files changed, 22 insertions(+), 24 deletions(-) rename archive/p/powershell/{Fizz-Buzz.ps1 => FizzBuzz.ps1} (97%) rename archive/p/powershell/{Hello-World.ps1 => HelloWorld.ps1} (100%) rename archive/p/powershell/{Reverse-String.ps1 => ReverseString.ps1} (55%) create mode 100644 archive/p/powershell/testinfo.yml diff --git a/archive/p/powershell/Fizz-Buzz.ps1 b/archive/p/powershell/FizzBuzz.ps1 similarity index 97% rename from archive/p/powershell/Fizz-Buzz.ps1 rename to archive/p/powershell/FizzBuzz.ps1 index 55ce5f04e..f9ec51ed5 100644 --- a/archive/p/powershell/Fizz-Buzz.ps1 +++ b/archive/p/powershell/FizzBuzz.ps1 @@ -44,10 +44,10 @@ print "FizzBuzz" [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] - $Min = 1, + [int]$Min = 1, [Parameter(Mandatory = $false, Position = 1)] - $Max = 100 + [int]$Max = 100 ) for ($X = $Min; $X -le $Max; $X++) { diff --git a/archive/p/powershell/Hello-World.ps1 b/archive/p/powershell/HelloWorld.ps1 similarity index 100% rename from archive/p/powershell/Hello-World.ps1 rename to archive/p/powershell/HelloWorld.ps1 diff --git a/archive/p/powershell/README.md b/archive/p/powershell/README.md index 2d2c16869..79218c881 100644 --- a/archive/p/powershell/README.md +++ b/archive/p/powershell/README.md @@ -55,18 +55,10 @@ The following list contains all of the approved programs that are not currently ## Testing -This language currently does not feature testing. If you'd like to help in the efforts to test all of the code in this repo, consider creating a testinfo.yml file with the following information: +The following list shares details about what we're using to test all Sample Programs in Powershell. -```yml -folder: - extension: - naming: - -container: - image: - tag: - cmd: -``` +- Docker Image: mcr.microsoft.com/powershell +- Docker Tag: lts-7.2-alpine-3.14 See the [Glotter2 project](https://github.com/rzuckerm/glotter2) for more information on how to create a testinfo file. diff --git a/archive/p/powershell/Reverse-String.ps1 b/archive/p/powershell/ReverseString.ps1 similarity index 55% rename from archive/p/powershell/Reverse-String.ps1 rename to archive/p/powershell/ReverseString.ps1 index 13dedcba2..ce693a506 100644 --- a/archive/p/powershell/Reverse-String.ps1 +++ b/archive/p/powershell/ReverseString.ps1 @@ -6,17 +6,17 @@ A simple script for reversing a String in PowerShell in order to show some features of the language. -.PARAMETER Input +.PARAMETER Str The string to reverse. .EXAMPLE - .\Reverse-String.ps1 -Input 'Hello, World' + .\ReverseString.ps1 -Str 'Hello, World' .EXAMPLE - .\Reverse-String.ps1 "Les Misérables" + .\ReverseString.ps1 "Les Misérables" .EXAMPLE - .\Reverse-String.ps1 "字樣樣品" + .\ReverseString.ps1 "字樣樣品" .NOTES This script does *not* support emoji as PowerShell only has full support for @@ -24,16 +24,14 @@ emoji within the ISE. #> param ( - [Parameter(Mandatory = $true, - Position = 0)] - [ValidateNotNullOrEmpty()] - [string]$Input + [Parameter(Mandatory = $false, Position = 0)] + [string]$Str ) -$StringBuilder = New-Object -TypeName System.Text.StringBuilder($Input.Length) +$StringBuilder = New-Object -TypeName System.Text.StringBuilder($Str.Length) -for ($x = ($Input.Length - 1); $x -ge 0; $x--) { - [void]$StringBuilder.Append($Input.Chars($x)) +for ($x = ($Str.Length - 1); $x -ge 0; $x--) { + [void]$StringBuilder.Append($Str.Chars($x)) } Write-Host $StringBuilder.ToString() diff --git a/archive/p/powershell/testinfo.yml b/archive/p/powershell/testinfo.yml new file mode 100644 index 000000000..cc9eed64e --- /dev/null +++ b/archive/p/powershell/testinfo.yml @@ -0,0 +1,8 @@ +folder: + extension: ".ps1" + naming: "pascal" + +container: + image: "mcr.microsoft.com/powershell" + tag: "lts-7.2-alpine-3.14" + cmd: "pwsh -file {{ source.name }}{{ source.extension }}"