Skip to content

Commit 1556b96

Browse files
Add tests for INPUT.
1 parent 7f857db commit 1556b96

13 files changed

Lines changed: 202 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT("left", "right")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(TRUE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(0d1.0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(LAMBDA BOOL: (){})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(0d1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(<>)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT(ASYNC{})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INPUT([0d1])
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
STR: line = INPUT()
11+
ASSERT(ISSTR(line))
12+
ASSERT(EQ(line, ""))
13+
'@
14+
15+
$result = Invoke-PrefixProgramWithInput -ProgramPath $programPath -InputText "`r`ntrailing`r`n"
16+
17+
Assert-PrefixSuccess $result
18+
Assert-NoErrorOutput $result
19+
20+
if ($result.Stdout.Length -ne 0) {
21+
$stdout = Format-VisibleText $result.Stdout
22+
throw "Expected no stdout output, got: $stdout"
23+
}
24+
}
25+
finally {
26+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
STR: line = INPUT("PROMPT>")
11+
ASSERT(EQ(line, "alpha"))
12+
PRINT("DONE=", line)
13+
'@
14+
15+
$result = Invoke-PrefixProgramWithInput -ProgramPath $programPath -InputText "alpha`r`n"
16+
17+
Assert-PrefixSuccess $result
18+
Assert-NoErrorOutput $result
19+
20+
if (-not [regex]::IsMatch($result.Stdout, '\APROMPT>DONE=alpha(?:\r\n|\n)\z')) {
21+
$stdout = Format-VisibleText $result.Stdout
22+
throw "Unexpected stdout: $stdout"
23+
}
24+
}
25+
finally {
26+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
27+
}

0 commit comments

Comments
 (0)