Skip to content

Commit cbe54a8

Browse files
committed
Added PowerShell teset for Nim
1 parent 7e7f29d commit cbe54a8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

nim/test.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$bin = "$PSScriptRoot\bin"
12+
13+
# First check if folder bin exists. If not, make a new bin folder.
14+
if (!(Test-Path -Path $bin)) {
15+
New-Item -Path $bin -Type Directory
16+
}
17+
18+
$Error.clear()
19+
nim c "$PSScriptRoot\permutations.nim" && . "$PSScriptRoot\permutations.exe" I like carrots |
20+
Compare-Object (Get-Content "$PSScriptRoot\..\test\carrots_expected") |
21+
Assert-MatchTests &&
22+
nim c "$PSScriptRoot\triple.nim" && . "$PSScriptRoot\triple.exe" |
23+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
24+
Assert-MatchTests &&
25+
ForEach-Object 'foo'
26+
27+
if ($Error -or !$?) {
28+
"*** NIM TESTS FAILED ***"
29+
}
30+
else {
31+
"NIM TESTS PASSED"
32+
}

0 commit comments

Comments
 (0)