Skip to content

Commit 464c573

Browse files
Add tests for WARN.
1 parent 1556b96 commit 464c573

9 files changed

Lines changed: 104 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN(LAMBDA BOOL: (){})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN(<"key" = 0d1>)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN(ASYNC{})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN([0d1])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN("ok", <"key" = 0d1>)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ASSERT(EQ(WARN(TRUE), FALSE))
2+
ASSERT(EQ(WARN(0d42), FALSE))
3+
ASSERT(EQ(WARN(0d1.5), FALSE))
4+
ASSERT(EQ(WARN("value"), FALSE))
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
6+
try {
7+
$programPath = Join-Path $tempDir 'program.pre'
8+
9+
Set-Content -Path $programPath -Encoding Ascii -Value @'
10+
ASSERT(EQ(WARN("bool=", TRUE, ",int=", 0d42, ",flt=", INF, ",str=", "ok"), FALSE))
11+
'@
12+
13+
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
14+
$startInfo.FileName = Get-PrefixExePath
15+
$startInfo.Arguments = ('"{0}"' -f $programPath)
16+
$startInfo.RedirectStandardOutput = $true
17+
$startInfo.RedirectStandardError = $true
18+
$startInfo.UseShellExecute = $false
19+
$startInfo.CreateNoWindow = $true
20+
21+
$process = [System.Diagnostics.Process]::Start($startInfo)
22+
try {
23+
$stdout = $process.StandardOutput.ReadToEnd()
24+
$stderr = $process.StandardError.ReadToEnd()
25+
$process.WaitForExit()
26+
27+
$result = [pscustomobject]@{
28+
ExitCode = $process.ExitCode
29+
Stdout = $stdout
30+
Stderr = $stderr
31+
}
32+
}
33+
finally {
34+
$process.Dispose()
35+
}
36+
37+
Assert-PrefixSuccess $result
38+
Assert-NoErrorOutput $result
39+
40+
if ($result.Stdout.Length -ne 0) {
41+
$stdout = Format-VisibleText $result.Stdout
42+
throw "Expected no stdout output, got: $stdout"
43+
}
44+
}
45+
finally {
46+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
6+
try {
7+
$programPath = Join-Path $tempDir 'program.pre'
8+
9+
Set-Content -Path $programPath -Encoding Ascii -Value @'
10+
ASSERT(EQ(WARN("bool=", TRUE, ",int=", 0d42, ",flt=", INF, ",str=", "ok"), TRUE))
11+
'@
12+
13+
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
14+
$startInfo.FileName = Get-PrefixExePath
15+
$startInfo.Arguments = ('-verbose "{0}"' -f $programPath)
16+
$startInfo.RedirectStandardOutput = $true
17+
$startInfo.RedirectStandardError = $true
18+
$startInfo.UseShellExecute = $false
19+
$startInfo.CreateNoWindow = $true
20+
21+
$process = [System.Diagnostics.Process]::Start($startInfo)
22+
try {
23+
$stdout = $process.StandardOutput.ReadToEnd()
24+
$stderr = $process.StandardError.ReadToEnd()
25+
$process.WaitForExit()
26+
27+
$result = [pscustomobject]@{
28+
ExitCode = $process.ExitCode
29+
Stdout = $stdout
30+
Stderr = $stderr
31+
}
32+
}
33+
finally {
34+
$process.Dispose()
35+
}
36+
37+
Assert-PrefixSuccess $result
38+
Assert-NoErrorOutput $result
39+
40+
if (-not [regex]::IsMatch($result.Stdout, '\AWARNING: bool=TRUE,int=0d42,flt=INF,str=ok(?:\r\n|\n)\z')) {
41+
$stdout = Format-VisibleText $result.Stdout
42+
throw "Unexpected stdout: $stdout"
43+
}
44+
}
45+
finally {
46+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
47+
}

0 commit comments

Comments
 (0)