Reject nonexistent native projection IDs and verify real split selection assignment
This commit is contained in:
@@ -23,7 +23,9 @@ function Step([string]$Name,[string[]]$Arguments=@(),[int]$Delay=500) {
|
||||
function Save([string]$Name) { Adb @('pull',$remote,(Join-Path $EvidenceDir "$Name.json")) | Out-Null; return Get-Content -LiteralPath (Join-Path $EvidenceDir "$Name.json") -Raw | ConvertFrom-Json }
|
||||
function Same($First,$Second) { return ($First | ConvertTo-Json -Depth 12 -Compress) -eq ($Second | ConvertTo-Json -Depth 12 -Compress) }
|
||||
function BallPoint($Board,[string]$Id) {
|
||||
$ball=@($Board.balls | Where-Object id -eq $Id)[0]; $camera=$Board.camera
|
||||
$matching=@($Board.balls | Where-Object id -eq $Id)
|
||||
if ($matching.Count -ne 1) { throw "Native projection requires exactly one existing ball ID: $Id" }
|
||||
$ball=$matching[0]; $camera=$Board.camera
|
||||
$rotation=[Numerics.Quaternion]::new($camera.rotation.x,$camera.rotation.y,$camera.rotation.z,$camera.rotation.w)
|
||||
$origin=[Numerics.Vector3]::new($camera.target.x,($camera.target.y+.65),$camera.target.z)+[Numerics.Vector3]::Transform([Numerics.Vector3]::new(0,0,-$camera.distance),$rotation)
|
||||
$local=[Numerics.Vector3]::Transform([Numerics.Vector3]::new($ball.position.x,$ball.position.y,$ball.position.z)-$origin,[Numerics.Quaternion]::Inverse($rotation))
|
||||
@@ -128,4 +130,3 @@ function CompareAudio([string]$Name,[string[]]$Ids) {
|
||||
Check "pcm-$Name-$id" ($exit -eq 0 -and $match.passed -and $match.normalizedCorrelation -ge .95 -and $match.rmsPcm -gt 32) ($match | ConvertTo-Json -Compress)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
param([Parameter(Mandatory)][string]$EvidenceDir,[string]$SelectorSource=(Join-Path $PSScriptRoot 'exercise-final-progression.ps1'))
|
||||
$ErrorActionPreference='Stop'
|
||||
New-Item -ItemType Directory -Path $EvidenceDir -Force|Out-Null
|
||||
$selector=@(Get-Content -LiteralPath $SelectorSource|Where-Object {$_-match'^\s*\$ids='})[0]
|
||||
if(!$selector){throw 'Missing actual SplitReal selection assignment'}
|
||||
$checks=[Collections.Generic.List[object]]::new()
|
||||
foreach($case in @(@{stage=10;size=1;expected='s10-b01'},@{stage=12;size=2;expected='s10-b01,s10-b02'},@{stage=13;size=2;expected='s10-b01,s10-b05'})){
|
||||
$Stage=$case.stage;$Selected=$case.size;$group=[pscustomobject]@{ballIds=@('s10-b01','s10-b02','s10-b03','s10-b04','s10-b05')}
|
||||
. ([scriptblock]::Create($selector))
|
||||
$passed=$ids-is[array]-and$ids.Count-eq$Selected-and($ids-join',')-eq$case.expected-and$ids[0]-eq's10-b01'
|
||||
$checks.Add(@{kind='actual-SplitReal-assignment';stage=$Stage;selected=$Selected;source=$selector;passed=$passed;ids=$ids;firstId=$ids[0];arrayType=$ids.GetType().FullName})
|
||||
}
|
||||
$ast=[Management.Automation.Language.Parser]::ParseFile((Join-Path $PSScriptRoot 'final-common.ps1'),[ref]$null,[ref]$null)
|
||||
$function=$ast.Find({param($n)$n-is[Management.Automation.Language.FunctionDefinitionAst]-and$n.Name-eq'BallPoint'},$true)
|
||||
. ([scriptblock]::Create($function.Extent.Text))
|
||||
$script:adbCalls=0
|
||||
function Adb([string[]]$Arguments){$script:adbCalls++;return 'Physical size: 1080x2400'}
|
||||
$board=[pscustomobject]@{balls=@([pscustomobject]@{id='s10-b01';position=[pscustomobject]@{x=-.5;y=.8;z=0}});camera=[pscustomobject]@{rotation=[pscustomobject]@{x=0;y=0;z=0;w=1};target=[pscustomobject]@{x=0;y=.6;z=0};distance=8}}
|
||||
foreach($id in @('s','missing','')){$rejected=$false;try{BallPoint $board $id|Out-Null}catch{$rejected=$true};$checks.Add(@{kind='missing-ID-before-ADB';id=$id;passed=($rejected-and$script:adbCalls-eq0);adbCalls=$script:adbCalls})}
|
||||
$point=BallPoint $board 's10-b01';$checks.Add(@{kind='valid-whole-ID-native-coordinate';point=$point;passed=($point.Count-eq2-and$script:adbCalls-eq1-and$point[0]-lt1200)})
|
||||
$passed=@($checks|Where-Object passed -ne $true).Count-eq0
|
||||
@{passed=$passed;sourceCommit=(& git rev-parse HEAD);selectorSource=$SelectorSource;checks=$checks.ToArray()}|ConvertTo-Json -Depth 5|Set-Content -LiteralPath (Join-Path $EvidenceDir 'selection-result.json')
|
||||
if(!$passed){exit 1};exit 0
|
||||
Reference in New Issue
Block a user