Skip to content

Commit

Permalink
Add Powershell Tests (#3093)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored and actions-user committed May 15, 2023
1 parent 64fda3f commit 102082d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
File renamed without changes.
14 changes: 3 additions & 11 deletions archive/p/powershell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@
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
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()
8 changes: 8 additions & 0 deletions archive/p/powershell/testinfo.yml
Original file line number Diff line number Diff line change
@@ -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 }}"

0 comments on commit 102082d

Please sign in to comment.