diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-11 20:08:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-11 21:45:12 -0300 |
| commit | 15de88cf82c187635c1989e91bfa639a10304066 (patch) | |
| tree | 16fa83854258c0c6aec1dff7f70ebabf5fd64c09 /anim/test | |
| parent | 0ec2376cae2fdfc50e90d930ebc86c7a5b7f5594 (diff) | |
| download | computeranim-15de88cf82c187635c1989e91bfa639a10304066.tar.gz computeranim-15de88cf82c187635c1989e91bfa639a10304066.zip | |
canim: a column of text as an experiment; the disassembly tied to the stack
From the user. A scene may set its text in a column beside the panes a
beat is about: col.beat names the panes and their rows, where the text
is placed (beside, below, above, or on a drawing) and what it is level
with; panes the beat leaves out fold to their title bars on a shelf,
their changes struck there. Tried as two scenes beside the originals:
the call followed down (column) and a bubble on sort's rings
(column_sort).
annotation = .tied names the word an instruction touched and draws a
touch to its stack row; offsets count from the frame's base; rsp's pin
travels with its amount before the stack follows; .whole keeps the full
chain. carry = .arrow draws a value's way between memory and a register.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/test')
| -rw-r--r-- | anim/test/column.script | 10 | ||||
| -rw-r--r-- | anim/test/column_sort.script | 10 | ||||
| -rw-r--r-- | anim/test/recordings.zig | 57 |
3 files changed, 75 insertions, 2 deletions
diff --git a/anim/test/column.script b/anim/test/column.script new file mode 100644 index 0000000..4a308d1 --- /dev/null +++ b/anim/test/column.script @@ -0,0 +1,10 @@ +# The column trial, headless: it runs to three instants of its timeline without failing +# (the opening in the working frame, a beat in the column, the close). +frames 2 +console set playing false +console set t 5 +screenshot .zig-cache/canim/column-early.png +console set t 30 +screenshot .zig-cache/canim/column-mid.png +console set t 999 +screenshot .zig-cache/canim/column-end.png diff --git a/anim/test/column_sort.script b/anim/test/column_sort.script new file mode 100644 index 0000000..540658b --- /dev/null +++ b/anim/test/column_sort.script @@ -0,0 +1,10 @@ +# The column on sort's rings, headless: it runs to three instants of its timeline without failing +# (the opening in the working frame, the drawing across both columns, the close). +frames 2 +console set playing false +console set t 5 +screenshot .zig-cache/canim/column_sort-early.png +console set t 20 +screenshot .zig-cache/canim/column_sort-mid.png +console set t 999 +screenshot .zig-cache/canim/column_sort-end.png diff --git a/anim/test/recordings.zig b/anim/test/recordings.zig index 7c3a26e..5f9ceb3 100644 --- a/anim/test/recordings.zig +++ b/anim/test/recordings.zig @@ -82,7 +82,8 @@ test "a walked step is as long as what it changed: fire, a slot a level, the hol fn frame(s: *anim.Frame) void { const r = canim.open(recordings.steps); at = canim.cursor(s, r, r.lineMoment(10, r.call("main", 0).enter)); - at.levels = .{ .idea = .calls }; + // The cascade as it was: `whole` (`tied` is the next test's). + at.levels = .{ .idea = .calls, .annotation = .whole }; } }; var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); @@ -101,11 +102,63 @@ test "a walked step is as long as what it changed: fire, a slot a level, the hol try expect(call.total > 2.0 and call.total < 3.5); // A line that changes nothing shown: fire, advance, rest. var quiet = scene.at; - quiet.levels = .{ .cpu = false, .memory = false }; + quiet.levels = .{ .cpu = false, .memory = false, .annotation = .whole }; const line = quiet.reading(rec.lineMoment(4, from), rec.lineMoment(6, from)); try std.testing.expectApproxEqAbs(t.fire + t.step + t.rest + t.step_per_row, line.total, 1e-3); } +test "under tied a step goes cause to effect: the touch, the word, rsp's pin, the window" { + const rec = canim.open(recordings.steps); + const scene = struct { + var at: canim.Cursor = undefined; + fn frame(s: *anim.Frame) void { + const r = canim.open(recordings.steps); + at = canim.cursor(s, r, r.call("fib", 1).enter - 1); + } + }; + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + var frame: anim.Frame = .{ .t = 0, .clock = 0, .in = undefined, .pointer = .{ 0, 0 }, .arena = arena.allocator() }; + scene.frame(&frame); + const f = 1.0 / 60.0; + // fib(5)'s `call fib` (by instruction): the touch to the free word over rsp 18 to 30, the return + // address armed 30 to 42 and struck at 42, rsp's pin 48 to 72 (struck as it lands), the window 78 on. + const call = rec.call("fib", 1).enter - 1; + const pushed = scene.at.reading(call, call + 1); + try std.testing.expectApproxEqAbs(@as(f32, 18 * f), pushed.touch, 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 42 * f), pushed.at[1], 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 48 * f), pushed.pins[0], 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 78 * f), pushed.follow, 1e-4); + try expect(pushed.pins[1] < 0 and pushed.advance > pushed.follow); + // `push rbp`, at the callee's entry: the same order. + const push = scene.at.reading(call + 1, call + 2); + try expect(push.touch < push.at[1] and push.at[1] < push.pins[0] and push.pins[0] < push.follow); + // `mov rbp, rsp`: no word; rbp's pin from 18 f, and no window to follow. + const frame_ptr = scene.at.reading(call + 2, call + 3); + try expect(frame_ptr.touch < 0 and frame_ptr.pins[0] < 0 and frame_ptr.follow < 0); + try std.testing.expectApproxEqAbs(@as(f32, 18 * f), frame_ptr.pins[1], 1e-4); + // A load that fills a register (`mov rax, [rbp - 0x10]`, fib(1)'s `return n`): the word read + // (its touch 18 to 30, framed at 30) before rax strikes (48). + var at = call; + var buf: [256]u8 = undefined; + while (!(std.mem.eql(u8, rec.instruction(at, rec.register(at, "rip"), &buf).?.text, "mov rax, qword ptr [rbp - 0x10]") and rec.registersChanged(at, at + 1) & 1 != 0)) at += 1; + const load = scene.at.reading(at, at + 1); + try std.testing.expectApproxEqAbs(@as(f32, 30 * f), load.read, 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 48 * f), load.at[0], 1e-4); + // With `carry = .arrow` the value's way between: carried 36 to 54, rax struck at 66. + var carrying = scene.at; + carrying.levels.carry = .arrow; + const carried = carrying.reading(at, at + 1); + try std.testing.expectApproxEqAbs(@as(f32, 36 * f), carried.carry, 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 66 * f), carried.at[0], 1e-4); + // `pop rbp`: the word read (framed at 30), then rbp's pin (it takes the word), then rsp's, then the window. + var pop = at; + while (!std.mem.eql(u8, rec.instruction(pop, rec.register(pop, "rip"), &buf).?.text, "pop rbp")) pop += 1; + const popped = scene.at.reading(pop, pop + 1); + try std.testing.expectApproxEqAbs(@as(f32, 30 * f), popped.read, 1e-4); + try expect(popped.read < popped.pins[1] and popped.pins[1] < popped.pins[0] and popped.pins[0] < popped.follow); +} + /// The first moment whose pc is in the function named `name` (as the recording names it: `libc.so.6!open`). fn firstIn(rec: *const Recording, name: []const u8) u64 { for (rec.registers, 0..) |regs, i| { |
