Skip to content

Commit 1100916

Browse files
Add tests for EXIT.
1 parent 1dacbe2 commit 1100916

11 files changed

Lines changed: 113 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(0d0, 0d1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(TRUE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(0d1.0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(LAMBDA BOOL: (){})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(<>)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT("0d1")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT(ASYNC{})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT([0d1])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EXIT()
2+
THROW("unreachable")
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
PRINT("custom")
11+
EXIT(0d23)
12+
PRINT("after")
13+
'@
14+
15+
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
16+
$startInfo.FileName = Get-PrefixExePath
17+
$startInfo.Arguments = ('"{0}"' -f $programPath)
18+
$startInfo.RedirectStandardOutput = $true
19+
$startInfo.RedirectStandardError = $true
20+
$startInfo.UseShellExecute = $false
21+
$startInfo.CreateNoWindow = $true
22+
23+
$process = [System.Diagnostics.Process]::Start($startInfo)
24+
try {
25+
$stdout = $process.StandardOutput.ReadToEnd()
26+
$stderr = $process.StandardError.ReadToEnd()
27+
$process.WaitForExit()
28+
29+
$result = [pscustomobject]@{
30+
ExitCode = $process.ExitCode
31+
Stdout = $stdout
32+
Stderr = $stderr
33+
}
34+
}
35+
finally {
36+
$process.Dispose()
37+
}
38+
39+
if ($result.ExitCode -ne 23) {
40+
$stdout = Format-VisibleText $result.Stdout
41+
$stderr = Format-VisibleText $result.Stderr
42+
throw "Expected Prefix to exit with code 23, got $($result.ExitCode)`nSTDOUT: $stdout`nSTDERR: $stderr"
43+
}
44+
45+
Assert-NoErrorOutput $result
46+
47+
if (-not [regex]::IsMatch($result.Stdout, '\Acustom(?:\r\n|\n)\z')) {
48+
$stdout = Format-VisibleText $result.Stdout
49+
throw "Unexpected stdout: $stdout"
50+
}
51+
}
52+
finally {
53+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
54+
}

0 commit comments

Comments
 (0)