Skip to content

Commit 102082d

Browse files
rzuckermactions-user
authored andcommitted
Add Powershell Tests (#3093)
1 parent 64fda3f commit 102082d

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ print "FizzBuzz"
4444
[CmdletBinding()]
4545
param (
4646
[Parameter(Mandatory = $false, Position = 0)]
47-
$Min = 1,
47+
[int]$Min = 1,
4848

4949
[Parameter(Mandatory = $false, Position = 1)]
50-
$Max = 100
50+
[int]$Max = 100
5151
)
5252

5353
for ($X = $Min; $X -le $Max; $X++) {

archive/p/powershell/README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,10 @@ The following list contains all of the approved programs that are not currently
5555

5656
## Testing
5757

58-
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:
58+
The following list shares details about what we're using to test all Sample Programs in Powershell.
5959

60-
```yml
61-
folder:
62-
extension:
63-
naming:
64-
65-
container:
66-
image:
67-
tag:
68-
cmd:
69-
```
60+
- Docker Image: mcr.microsoft.com/powershell
61+
- Docker Tag: lts-7.2-alpine-3.14
7062

7163
See the [Glotter2 project](https://github.com/rzuckerm/glotter2) for more information on how to create a testinfo file.
7264

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,32 @@
66
A simple script for reversing a String in PowerShell in order to show some
77
features of the language.
88
9-
.PARAMETER Input
9+
.PARAMETER Str
1010
The string to reverse.
1111
1212
.EXAMPLE
13-
.\Reverse-String.ps1 -Input 'Hello, World'
13+
.\ReverseString.ps1 -Str 'Hello, World'
1414
1515
.EXAMPLE
16-
.\Reverse-String.ps1 "Les Misérables"
16+
.\ReverseString.ps1 "Les Misérables"
1717
1818
.EXAMPLE
19-
.\Reverse-String.ps1 "字樣樣品"
19+
.\ReverseString.ps1 "字樣樣品"
2020
2121
.NOTES
2222
This script does *not* support emoji as PowerShell only has full support for
2323
emoji within the ISE.
2424
#>
2525
param
2626
(
27-
[Parameter(Mandatory = $true,
28-
Position = 0)]
29-
[ValidateNotNullOrEmpty()]
30-
[string]$Input
27+
[Parameter(Mandatory = $false, Position = 0)]
28+
[string]$Str
3129
)
3230

33-
$StringBuilder = New-Object -TypeName System.Text.StringBuilder($Input.Length)
31+
$StringBuilder = New-Object -TypeName System.Text.StringBuilder($Str.Length)
3432

35-
for ($x = ($Input.Length - 1); $x -ge 0; $x--) {
36-
[void]$StringBuilder.Append($Input.Chars($x))
33+
for ($x = ($Str.Length - 1); $x -ge 0; $x--) {
34+
[void]$StringBuilder.Append($Str.Chars($x))
3735
}
3836

3937
Write-Host $StringBuilder.ToString()

archive/p/powershell/testinfo.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
folder:
2+
extension: ".ps1"
3+
naming: "pascal"
4+
5+
container:
6+
image: "mcr.microsoft.com/powershell"
7+
tag: "lts-7.2-alpine-3.14"
8+
cmd: "pwsh -file {{ source.name }}{{ source.extension }}"

0 commit comments

Comments
 (0)