|
- # E04-S04: run the control-flow fixture and check sizing, branch forms, and
- # the executed if/else/while/for/call/return results.
- [CmdletBinding()]
- param(
- [int]$Port = 6530,
- [int]$TimeoutSeconds = 90
- )
-
- $ErrorActionPreference = "Stop"
- $project = Split-Path $PSScriptRoot -Parent
- Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force
- & (Join-Path $PSScriptRoot "build-control-test.ps1")
-
- $out = Join-Path $project "build\control-test"
- $prg = Join-Path $out "control-test.prg"
- $session = Start-Nova128X128 -Autostart $prg -Port $Port `
- -Screenshot (Join-Path $out "control-test-vicii.png")
- try {
- $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds
- } finally {
- Stop-Nova128X128 $session
- }
-
- Write-Host ('mailbox: ' + (($mb | ForEach-Object { $_.ToString('X2') }) -join ' '))
- Write-Host (("results: return={0} a={1} path={2} i={3} long={4:X2} bad={5} mismatches={6} forms={7:X2}" -f `
- $mb[8], $mb[9], $mb[10], $mb[11], $mb[12], $mb[13], $mb[14], $mb[15]))
-
- $failures = @()
- if ($mb[2] -ne 0x03) { $failures += "producer $($mb[2]) is not a generated program" }
- if ($mb[3] -ne 0xA5) { $failures += "fixture status is not PASS" }
- if ($mb[4] -ne 0 -or $mb[5] -ne 0) { $failures += "code is $($mb[4] + 256 * $mb[5])" }
- if ($mb[8] -ne 17) { $failures += "program result is $($mb[8]), expected 17" }
- if ($mb[9] -ne 5) { $failures += "while/a is $($mb[9]), expected 5" }
- if ($mb[10] -ne 10) { $failures += "if/else path is $($mb[10]), expected 10" }
- if ($mb[11] -ne 4) { $failures += "for/i is $($mb[11]), expected 4" }
- if ($mb[12] -ne 0x5A) { $failures += ('long branch result is {0:X2}, expected 5A' -f $mb[12]) }
- if ($mb[13] -ne 0) { $failures += "long branch ran the wrong path" }
- if ($mb[14] -ne 0) { $failures += "$($mb[14]) sizing label/length mismatches" }
- if ($mb[15] -ne 3) { $failures += ('branch forms are {0:X2}, expected 03 (short and long verified)' -f $mb[15]) }
-
- if ($failures) { throw ("control verification failed:`n " + ($failures -join "`n ")) }
- Write-Host "verified sizing pass, short/long branches, if/else, while, for, call, and return"
|