The cell and terminal list checks now run as one Ziran module whose SelfTest walks both case sets. The geometry suite's table runs its camera cases, which no script ran before, then the vector path and view transform behaviors. Each pair compiled through the same commands, so behavior scripts drop from 179 to 177 with the same assertions; the plan maps both removals.
39 lines
1.4 KiB
Ziran
39 lines
1.4 KiB
Ziran
// Camera mapping, vector paths and view transforms run as one table of
|
|
// cases. Each case returns 0 or its own failure code; a failure reports the
|
|
// case number in the hundreds.
|
|
#import "geometry"
|
|
VectorPath :: #import "vector_path_behavior";
|
|
ViewTransform :: #import "view_transform_behavior";
|
|
|
|
Near :: (a: float32, b: float32) -> bool {
|
|
delta: float32 = a - b
|
|
return delta > -0.001 && delta < 0.001
|
|
}
|
|
|
|
// A camera maps world points to the screen and back, and a zero zoom maps
|
|
// every screen point to the camera's target.
|
|
CameraCases :: () -> s32 {
|
|
camera: Camera = Camera.{Vector2.{100.0, 50.0},
|
|
Vector2.{10.0, 20.0}, 90.0, 2.0}
|
|
screen: Vector2 = WorldToScreen(Vector2.{11.0, 20.0}, camera)
|
|
if !Near(screen.x, 100.0) || !Near(screen.y, 52.0) { return 1 }
|
|
world: Vector2 = ScreenToWorld(screen, camera)
|
|
if !Near(world.x, 11.0) || !Near(world.y, 20.0) { return 2 }
|
|
camera.zoom = 0.0
|
|
world = ScreenToWorld(screen, camera)
|
|
if !Near(world.x, 10.0) || !Near(world.y, 20.0) { return 3 }
|
|
return 0
|
|
}
|
|
|
|
#program_export
|
|
main :: () -> s32 {
|
|
for index: cast(s32)0..2 {
|
|
failure: s32
|
|
if index == 0 { failure = CameraCases() }
|
|
else if index == 1 { failure = VectorPath.VectorPathCases() }
|
|
else { failure = ViewTransform.ViewTransformCases() }
|
|
if failure != 0 { return (index + 1) * 100 + failure }
|
|
}
|
|
return 0
|
|
}
|